fsync() doesn't work as advertised?

Antoine Pitrou solipsis at pitrou.net
Mon Jan 4 17:29:45 CET 2010

Le Mon, 04 Jan 2010 08:09:56 -0800, Brian D a écrit :
> 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.

Perhaps you are writing to the file from several threads or processes at 

By the way, you shouldn't need fsync() if you merely want to look at the 
log files, because your OS will have an up-to-date view of the file 
contents anyway. fsync() is useful if you want to be sure the data has 
been written to the hard disk drive, rather than just kept in the 
operating system's filesystem cache.

More information about the Python-list mailing list