cpython: de962ec0faaa (original) (raw)
Mercurial > cpython
changeset 74037:de962ec0faaa 3.2
Issue #11870: threading: Properly reinitialize threads internal locks and condition variables to avoid deadlocks in child processes. [#11870]
Charles-François Natali neologix@free.fr | |
---|---|
date | Sun, 18 Dec 2011 18:35:09 +0100 |
parents | a420b27a86d9 |
children | 336805423372 fa5c8cf29963 a175284ede57 |
files | Lib/threading.py Misc/NEWS |
diffstat | 2 files changed, 7 insertions(+), 7 deletions(-)[+] [-] Lib/threading.py 11 Misc/NEWS 3 |
line wrap: on
line diff
--- a/Lib/threading.py +++ b/Lib/threading.py @@ -1068,21 +1068,18 @@ def _after_fork(): current = current_thread() with _active_limbo_lock: for thread in _active.values():
# Any lock/condition variable may be currently locked or in an[](#l1.7)
# invalid state, so we reinitialize them.[](#l1.8)
thread._reset_internal_locks()[](#l1.9) if thread is current:[](#l1.10) # There is only one active thread. We reset the ident to[](#l1.11) # its new value since it can have changed.[](#l1.12) ident = _get_ident()[](#l1.13) thread._ident = ident[](#l1.14)
# Any condition variables hanging off of the active thread may[](#l1.15)
# be in an invalid state, so we reinitialize them.[](#l1.16)
thread._reset_internal_locks()[](#l1.17) new_active[ident] = thread[](#l1.18) else:[](#l1.19) # All the others are already stopped.[](#l1.20)
# We don't call _Thread__stop() because it tries to acquire[](#l1.21)
# thread._Thread__block which could also have been held while[](#l1.22)
# we forked.[](#l1.23)
thread._stopped = True[](#l1.24)
thread._stop()[](#l1.25)
_limbo.clear() _active.clear()
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -97,6 +97,9 @@ Core and Builtins Library ------- +- Issue #11870: threading: Properly reinitialize threads internal locks and