summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles-François Natali <neologix@free.fr>2011-12-18 17:45:16 (GMT)
committerCharles-François Natali <neologix@free.fr>2011-12-18 17:45:16 (GMT)
commitb055bf6acbac7245ea943143be7313912a692902 (patch)
tree4d88b45e1bdfe9cc596bb94b4dc43c6aef2d7c37
parent3c4dcea71267ac7c418a55454d85a4703116c774 (diff)
downloadcpython-b055bf6acbac7245ea943143be7313912a692902.zip
cpython-b055bf6acbac7245ea943143be7313912a692902.tar.gz
cpython-b055bf6acbac7245ea943143be7313912a692902.tar.bz2
Issue #11870: threading: Properly reinitialize threads internal locks and
condition variables to avoid deadlocks in child processes.
-rw-r--r--Lib/threading.py11
-rw-r--r--Misc/NEWS3
2 files changed, 7 insertions, 7 deletions
diff --git a/Lib/threading.py b/Lib/threading.py
index 8d505b7..2362be6 100644
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -1047,21 +1047,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
+ # invalid state, so we reinitialize them.
+ thread._reset_internal_locks()
if thread is current:
# There is only one active thread. We reset the ident to
# its new value since it can have changed.
ident = get_ident()
thread._ident = ident
- # Any condition variables hanging off of the active thread may
- # be in an invalid state, so we reinitialize them.
- thread._reset_internal_locks()
new_active[ident] = thread
else:
# All the others are already stopped.
- # We don't call _Thread__stop() because it tries to acquire
- # thread._Thread__block which could also have been held while
- # we forked.
- thread._stopped = True
+ thread._stop()
_limbo.clear()
_active.clear()
diff --git a/Misc/NEWS b/Misc/NEWS
index 85667cc..2114c4b 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -419,6 +419,9 @@ Core and Builtins
Library
-------
+- Issue #11870: threading: Properly reinitialize threads internal locks and
+ condition variables to avoid deadlocks in child processes.
+
- Issue #8035: urllib: Fix a bug where the client could remain stuck after a
redirection or an error.