From a924fc7abc2d8788a4a9fa2cbef2caa5c5992ebd Mon Sep 17 00:00:00 2001 From: Charles-François Natali Date: Sun, 25 May 2014 14:12:12 +0100 Subject: Issue #21565: multiprocessing: use contex-manager protocol for synchronization primitives. --- Lib/multiprocessing/util.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Lib/multiprocessing/util.py') diff --git a/Lib/multiprocessing/util.py b/Lib/multiprocessing/util.py index 0b695e46e59..8760c823df3 100644 --- a/Lib/multiprocessing/util.py +++ b/Lib/multiprocessing/util.py @@ -327,6 +327,13 @@ class ForkAwareThreadLock(object): self.acquire = self._lock.acquire self.release = self._lock.release + def __enter__(self): + return self._lock.__enter__() + + def __exit__(self, *args): + return self._lock.__exit__(*args) + + class ForkAwareLocal(threading.local): def __init__(self): register_after_fork(self, lambda obj : obj.__dict__.clear()) -- cgit v1.2.3