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

gabor gabor at nekomancer.net
Fri May 27 08:32:53 EDT 2005


hi,

what i want to achieve:
i have a cgi file, that writes an entry to a text-file..
like a log entry (when was it invoked, when did his worke end).
it's one line of text.

the problem is:
what happens if 2 users invoke the cgi at the same time?

and it will happen, because i am trying now to stress test it, so i will 
start 5-10 requests in parallel and so on.

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 :(

another idea was to use a simple database (sqlite?) which probably has 
this problem solved already...

any better ideas?

thanks,
gabor



More information about the Python-list mailing list