A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/097396.html below:

File locking

File lockingMartin 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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4