Skip to content

bpo-40221: Update ForkAwareThreadLock to use _at_fork_reinit #19477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Lib/multiprocessing/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,13 +367,13 @@ def _exit_function(info=info, debug=debug, _run_finalizers=_run_finalizers,

class ForkAwareThreadLock(object):
def __init__(self):
self._reset()
register_after_fork(self, ForkAwareThreadLock._reset)

def _reset(self):
self._lock = threading.Lock()
self.acquire = self._lock.acquire
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):
return self._lock.__enter__()
Expand Down