write to the same file from multiple processes at the same time?

Paul Rubin http
Fri May 27 08:49:49 EDT 2005


gabor <gabor at nekomancer.net> writes:
> so, how does one synchronizes several processes in python?
> 
> first idea was that the cgi will create a new temp file every time,
> and at the end of the stress-test, i'll collect the content of all
> those files. but that seems as a stupid way to do it :(

There was a thread about this recently ("low-end persistence
strategies") and for Unix the simplest answer seems to be the
fcntl.flock function.  For Windows I don't know the answer.
Maybe os.open with O_EXCL works.




More information about the Python-list mailing list