safe simultaneous file append?

piet at cs.uu.nl piet at cs.uu.nl
Mon Oct 8 06:02:52 EDT 2001


>>>>> Dale Strickland-Clark <dale at riverhall.NOSPAMco.uk> (DS) writes:

DS> Yes. You can't append to a file from two different places at once. You
DS> have a few choices:

In fact in modern Unixes you *CAN*.
>From man fopen:

     Opening a file with append mode (a as the first character in
     the  mode argument) causes all subsequent writes to the file
     to be forced to the then current end-of-file, regardless  of
     intervening  calls  to fseek(3S).  If two separate processes
     open the same file for append, each process may write freely
     to  the file without fear of destroying output being written
     by the other.  The output from the  two  processes  will  be
     intermixed in the file in the order in which it is written.

-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum at hccnet.nl



More information about the Python-list mailing list