diff options
Diffstat (limited to 'Mailman/LockFile.py')
| -rw-r--r-- | Mailman/LockFile.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Mailman/LockFile.py b/Mailman/LockFile.py index b240ce5a4..d83cef7e2 100644 --- a/Mailman/LockFile.py +++ b/Mailman/LockFile.py @@ -321,6 +321,16 @@ class LockFile: if self._owned: self.finalize() + # Python 2.5 context manager protocol support. + def __enter__(self): + self.lock() + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + self.unlock() + # Don't suppress any exception that might have occurred. + return False + # Use these only if you're transfering ownership to a child process across # a fork. Use at your own risk, but it should be race-condition safe. # _transfer_to() is called in the parent, passing in the pid of the child. |
