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

Erno Kuusela erno-news at erno.iki.fi
Mon Apr 8 01:50:10 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?

you can open files with buffering disabled by passing 0 as the
3rd argument to open().

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.

the above two things just make sure the os knows about the 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