diff options
| author | bwarsaw | 2007-05-28 20:21:41 +0000 |
|---|---|---|
| committer | bwarsaw | 2007-05-28 20:21:41 +0000 |
| commit | b18f632faa6de17badabb3c6c7ba61752ac84c37 (patch) | |
| tree | 8b444330b288c5dfc9b25be639d429abfaeb3d3d /Mailman/LockFile.py | |
| parent | 5ff792b13599920527b48f92f8bad880668f8f26 (diff) | |
| download | mailman-b18f632faa6de17badabb3c6c7ba61752ac84c37.tar.gz mailman-b18f632faa6de17badabb3c6c7ba61752ac84c37.tar.zst mailman-b18f632faa6de17badabb3c6c7ba61752ac84c37.zip | |
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. |
