knowing when file is flushed to disk

John Pote johnpote at blueyonder.co.uk
Wed Aug 9 12:13:19 EDT 2006


Hello,

I'm using a Python CGI script on a web server to log data from a remote site 
every few minutes. I do not want to lose any data for whatever rare reason - 
power outage/os crash just at the wrong moment etc. So I would like to know 
when the data is actually written to disk and the file closed. At that point 
I can signal deleting of the data at the remote site which has very limited 
storage.

Is there some way from my Python script to know when the data is actually on 
the disk. BTW server OS is Linux. Presumably calling flush() and close() on 
the output file will initiate the disk write, but do they wait for the 
actual disk write or immediately return leaving the OS to do the write when 
it sees fit?

Any thoughts appreciated,

John 





More information about the Python-list mailing list