##// END OF EJS Templates
Add fsync() call in atomic_writing
Thomas Kluyver -
Show More
@@ -260,15 +260,19 b" def atomic_writing(path, text=True, encoding='utf-8', **kwargs):"
260 fileobj.close()
260 fileobj.close()
261 os.remove(tmp_path)
261 os.remove(tmp_path)
262 raise
262 raise
263 else:
264 # Written successfully, now rename it
265 fileobj.close()
266
263
267 if os.name == 'nt' and os.path.exists(path):
264 # Flush to disk
268 # Rename over existing file doesn't work on Windows
265 fileobj.flush()
269 os.remove(path)
266 os.fsync(fileobj.fileno())
267
268 # Written successfully, now rename it
269 fileobj.close()
270
271 if os.name == 'nt' and os.path.exists(path):
272 # Rename over existing file doesn't work on Windows
273 os.remove(path)
270
274
271 os.rename(tmp_path, path)
275 os.rename(tmp_path, path)
272
276
273
277
274 def raw_print(*args, **kw):
278 def raw_print(*args, **kw):
General Comments 0
You need to be logged in to leave comments. Login now