"what exactly the python's file.flush() is doing?" says you should first f.flush()
and then os.fsync(f.fileno())
to make sure the data are written to the disk.
Furthermore, "does close() imply flush() in Python?" claims that f.close()
implies a flush()
.
Now, the question is: should I do
os.fsync(f.fileno())
f.close()
or, does f.close()
also implies an os.fsync()
?
Here are the doc of Python IO, the doc of Python file close, and the source code. A quick search of 'fsync' returned no relevant info.
f.close()
and nobody had problem with saved data. – Henandchickensclose()
returns? – Impermanent