mirror of
https://github.com/python/cpython.git
synced 2025-08-23 18:24:46 +00:00
Issue #21565: multiprocessing: use contex-manager protocol for synchronization
primitives.
This commit is contained in:
parent
1691e35953
commit
a924fc7abc
9 changed files with 43 additions and 102 deletions
|
@ -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())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue