On Sun, Mar 13, 2011 at 3:15 AM, Tim Allen <screwt...@froup.com> wrote:
> On Sat, Mar 12, 2011 at 02:33:45PM +0200, Pandelis Theodosiou wrote: > > On Sat, Mar 12, 2011 at 3:32 AM, Tim Allen <screwt...@froup.com> wrote: > > > Of course, if you flush after every disk read, your program will run > > > a bit more slowly and with more I/O... for an application where > > > reliability is more important than performance (like logging) that's > > > probably acceptable. > > > > You may also setup a timer that flushes files every, say, 5 minutes. > > > > One other thing I've read in the Python.org site is that flush() is not > 100% > > sure to work immediately and should be used in combination with > os.fsync(). > > Is there someone that can explain if that is correct? > > Depends what you mean by 'work'. The standard library (Python's or C's) > buffers reads and writes because calling into the kernel is expensive. > The kernel buffers reads and writes because disk I/O is even more > expensive. flush() tells the standard library "send buffered data to the > kernel right now" which means your data should survive if your process > crashes. fsync() tells the kernel "send buffered data to the disk right > now", which means your data should survive if the entire machine > crashes. > > Whether you call nothing, just flush(), or both flush() and fsync() > depends on how your software balances performance versus reliability. > > > thnx, very clear explanation. <http://int.ask.com/web?siteid=10000861&webqsrc=999&l=dis&q=_______________________________________________>
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python