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

ucntcme at gmail.com ucntcme at gmail.com
Sun May 29 01:32:41 EDT 2005


Well I just tried it on Linux anyway. I opened the file in two python
processes using append mode.

I then wrote simple function to write then flush what it is passed:

def write(msg):
   foo.write("%s\n" %  msg)
   foo.flush()

I then opened another terminal and did 'tail -f myfile.txt'.

It worked just fine.

Maybe that will help. Seems simple enough to me for basic logging.

Cheers,
Bill




More information about the Python-list mailing list