[Twisted-Python] UDP Logging Server
ypercube at gmail.com
Sun Mar 13 06:37:10 EDT 2011
On Sun, Mar 13, 2011 at 3:15 AM, Tim Allen <screwtape at 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 <screwtape at 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
> > sure to work immediately and should be used in combination with
> > 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
> Whether you call nothing, just flush(), or both flush() and fsync()
> depends on how your software balances performance versus reliability.
thnx, very clear explanation.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Twisted-Python