purging file buffers - to make new data be written to file

Erno Kuusela erno-news at erno.iki.fi
Mon Apr 8 01:47:59 EDT 2002


In article <a8qhjp$7go$1 at news6.svr.pol.co.uk>, ddoc
<news at 92tr.freeserve.co.uk> writes:

| Can I do that from within a python script, or do I have to give a command 
| line argument to make Python start without buffers?

| On Linux.  The program is to save a memo in a slightly organised format, 
| but I find the file is not written until Python exits.

f.flush() will commit any data that python and the c library might
have not yet written to the operating system. this will let
other processes in the system see the new data.

if you want to make sure the data ends up on disk physically,
use os.fsync(f.fileno()).

  -- erno



More information about the Python-list mailing list