diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2006-06-26 13:12:16 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2006-06-26 13:12:16 (GMT) |
commit | 557325930ce81804a1dd9c6f0e3babb8673afdd5 (patch) | |
tree | 00724b40d83d8720b7208f611356af5ed3ab354e /Lib/mailbox.py | |
parent | a7ee9eb3d95f9c4dfb0fa8e52523cb46959e2301 (diff) | |
download | cpython-557325930ce81804a1dd9c6f0e3babb8673afdd5.zip cpython-557325930ce81804a1dd9c6f0e3babb8673afdd5.tar.gz cpython-557325930ce81804a1dd9c6f0e3babb8673afdd5.tar.bz2 |
[Bug #1512163] Use one set of locking methods, lockf();
remove the flock() calls.
On FreeBSD, the two methods lockf() and flock() end up using the same
mechanism and the second one fails. A Linux man page claims that the
two methods are orthogonal (so locks acquired one way don't interact
with locks acquired the other way) but that clearly must be false.
Diffstat (limited to 'Lib/mailbox.py')
-rwxr-xr-x | Lib/mailbox.py | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/Lib/mailbox.py b/Lib/mailbox.py index 3777c8e..02fbb85 100755 --- a/Lib/mailbox.py +++ b/Lib/mailbox.py @@ -1798,7 +1798,7 @@ class _PartialFile(_ProxyFile): def _lock_file(f, dotlock=True): - """Lock file f using lockf, flock, and dot locking.""" + """Lock file f using lockf and dot locking.""" dotlock_done = False try: if fcntl: @@ -1810,14 +1810,6 @@ def _lock_file(f, dotlock=True): f.name) else: raise - try: - fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB) - except IOError, e: - if e.errno == errno.EWOULDBLOCK: - raise ExternalClashError('flock: lock unavailable: %s' % - f.name) - else: - raise if dotlock: try: pre_lock = _create_temporary(f.name + '.lock') @@ -1845,16 +1837,14 @@ def _lock_file(f, dotlock=True): except: if fcntl: fcntl.lockf(f, fcntl.LOCK_UN) - fcntl.flock(f, fcntl.LOCK_UN) if dotlock_done: os.remove(f.name + '.lock') raise def _unlock_file(f): - """Unlock file f using lockf, flock, and dot locking.""" + """Unlock file f using lockf and dot locking.""" if fcntl: fcntl.lockf(f, fcntl.LOCK_UN) - fcntl.flock(f, fcntl.LOCK_UN) if os.path.exists(f.name + '.lock'): os.remove(f.name + '.lock') |