summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDana Powers <dana.powers@gmail.com>2016-03-12 12:53:47 -0800
committerDana Powers <dana.powers@gmail.com>2016-03-12 12:53:47 -0800
commitbbca721d74cf02983e34cf187d8f032609f7c484 (patch)
tree3f08a72014b6718b13c5fdcf39559e12d6c3e810 /test
parent590d75a76a4b9d666a0340daef8ef328ca87e066 (diff)
downloadkafka-python-bbca721d74cf02983e34cf187d8f032609f7c484.tar.gz
Sync rendered fixture templates to disk to avoid races
Diffstat (limited to 'test')
-rw-r--r--test/fixtures.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/fixtures.py b/test/fixtures.py
index 3c5e694..7da4f52 100644
--- a/test/fixtures.py
+++ b/test/fixtures.py
@@ -84,6 +84,14 @@ class Fixture(object):
template = handle.read()
with open(target_file, "w") as handle:
handle.write(template.format(**binding))
+ handle.flush()
+ os.fsync(handle)
+
+ # fsync directory for durability
+ # https://blog.gocept.com/2013/07/15/reliable-file-updates-with-python/
+ dirfd = os.open(os.path.dirname(target_file), os.O_DIRECTORY)
+ os.fsync(dirfd)
+ os.close(dirfd)
class ZookeeperFixture(Fixture):