File locking
Martin Kaufmann
martinkaufmann at yahoo.com
Tue Apr 24 11:02:36 EDT 2001
Could somebody help me? I have a script that writes its output in a
logfile. This logfile is needed to check whether a task has already be
done. Several workstations are now using the same script (via nfs). So I
implemented the following file locking mechanism:
logfile = posixfile.open(LOGFILE, 'a')
logfile.lock('|w')
[code snipped...]
log_string = '%s %s%s %d %s %s\n' % (mytime, host, url,
error_code, message, hostname)
logfile.write(log_string)
logfile.lock('u')
logfile.close()
But I still get problems with two processes trying to write at the same
time. What is wrong with my implementation?
Thanks for your help.
Regards,
Martin
--
There is a difference between knowing the path and walking the path.
More information about the Python-list
mailing list