fsync() doesn't work as advertised?
Brian D
briandenzer at gmail.com
Mon Jan 4 13:09:16 EST 2010
On Jan 4, 10:29 am, Antoine Pitrou <solip... at pitrou.net> wrote:
> 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
> once?
>
> 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.
Sure -- I hadn't considered how threads might affect the write
process. That's a good lead to perhaps fixing the problem.
Thanks for your help, Antoine.
More information about the Python-list
mailing list