mirror of
https://github.com/python/cpython.git
synced 2025-10-06 15:11:58 +00:00
Issue #17555: Fix ForkAwareThreadLock so that size of after fork
registry does not grow exponentially with generation of process.
This commit is contained in:
parent
b38897fc91
commit
409c31390f
3 changed files with 38 additions and 2 deletions
|
@ -322,10 +322,13 @@ atexit.register(_exit_function)
|
|||
|
||||
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.__init__)
|
||||
|
||||
class ForkAwareLocal(threading.local):
|
||||
def __init__(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue