mirror of
https://github.com/python/cpython
synced 2024-09-16 03:39:58 +00:00
bpo-40221: Update multiprocessing to use _at_fork_reinit (GH-19477)
This commit is contained in:
parent
81a7be3fa2
commit
e1945307d3
|
@ -367,13 +367,13 @@ def _exit_function(info=info, debug=debug, _run_finalizers=_run_finalizers,
|
||||||
|
|
||||||
class ForkAwareThreadLock(object):
|
class ForkAwareThreadLock(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._reset()
|
|
||||||
register_after_fork(self, ForkAwareThreadLock._reset)
|
|
||||||
|
|
||||||
def _reset(self):
|
|
||||||
self._lock = threading.Lock()
|
self._lock = threading.Lock()
|
||||||
self.acquire = self._lock.acquire
|
self.acquire = self._lock.acquire
|
||||||
self.release = self._lock.release
|
self.release = self._lock.release
|
||||||
|
register_after_fork(self, ForkAwareThreadLock._at_fork_reinit)
|
||||||
|
|
||||||
|
def _at_fork_reinit(self):
|
||||||
|
self._lock._at_fork_reinit()
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
return self._lock.__enter__()
|
return self._lock.__enter__()
|
||||||
|
|
Loading…
Reference in a new issue