File locking using fcntl.flock()
Donn Cave
donn at u.washington.edu
Wed Apr 17 11:41:49 EDT 2002
Quoth Richard Jones <rjones at ekit-inc.com>:
| On Wed, 17 Apr 2002 03:38, Donn Cave wrote:
...
| > I don't have Solaris, but I bet it doesn't have flock.
|
| It does, under the heading of "BSD compatibility".
For python, that would make 2 questions: 1) was python built with
the BSD compatibility, and 2) is flock() a bona fide implementation
or does it call fcntl. The answer to one or both is apparently "no",
or you'd get flock semantics.
| That's almost a moot point though, because I also mentioned that I tried both
| fcntl.lockf() ("This is essentially a wrapper around the fcntl() locking
| calls.") and posixfile.lock() and neither of those worked either. The _real_
| problem here is that Solaris appears to allow a process to have two locks on
| a single file in the same process. Things are fine if the lock is requested
| from separate processes.
I think I explained this. It isn't just Solaris. Those functions will
have the same semantics on NetBSD etc.
| Thus in separate processes fcntl.lockf() and friends work fine. This is
| troublesome because threads can't use file locks. Just gotta avoid threading
That's a good idea in general, anyway.
Donn Cave, donn at u.washington.edu
More information about the Python-list
mailing list