fsync() doesn't work as advertised?

Brian D briandenzer at gmail.com
Mon Jan 4 11:09:56 EST 2010


If I'm running a process in a loop that runs for a long time, I
occasionally would like to look at a log to see how it's going.

I know about the logging module, and may yet decide to use that.

Still, I'm troubled by how fsync() doesn't seem to work as advertised:

http://docs.python.org/library/os.html

"If you’re starting with a Python file object f, first do f.flush(),
and then do os.fsync(f.fileno())"

Has anyone else experienced and overcome this issue?

What I've seen is that flush() alone produces a complete log when the
loop finishes. When I used fsync(), I lost all of the write entries
except the first, along with odd error trap and the last entry.



More information about the Python-list mailing list