summaryrefslogtreecommitdiffstats
path: root/Lib/threading.py
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-04-03 23:07:55 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-04-03 23:07:55 (GMT)
commitd7a265129c292f2a50d3daefd8a133fe97a3bf78 (patch)
treec8e883142a0aad5d036b03c2eb824640b2377f0f /Lib/threading.py
parent2aae1d92ebf442b08efce2bc5d090d70fb92e525 (diff)
downloadcpython-d7a265129c292f2a50d3daefd8a133fe97a3bf78.zip
cpython-d7a265129c292f2a50d3daefd8a133fe97a3bf78.tar.gz
cpython-d7a265129c292f2a50d3daefd8a133fe97a3bf78.tar.bz2
#1733757: the interpreter would hang on shutdown, if the function set by sys.settrace
calls threading.currentThread. The correction somewhat improves the code, but it was close. Many thanks to the "with" construct, which turns python code into C calls. I wonder if it is not better to sys.settrace(None) just after running the __main__ module and before finalization.
Diffstat (limited to 'Lib/threading.py')
-rw-r--r--Lib/threading.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/Lib/threading.py b/Lib/threading.py
index 516e22d..d497a46 100644
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -583,15 +583,16 @@ class Thread(_Verbose):
# since it isn't if dummy_threading is *not* being used then don't
# hide the exception.
- _active_limbo_lock.acquire()
try:
- try:
+ with _active_limbo_lock:
del _active[_get_ident()]
- except KeyError:
- if 'dummy_threading' not in _sys.modules:
- raise
- finally:
- _active_limbo_lock.release()
+ # There must not be any python code between the previous line
+ # and after the lock is released. Otherwise a tracing function
+ # could try to acquire the lock again in the same thread, (in
+ # currentThread()), and would block.
+ except KeyError:
+ if 'dummy_threading' not in _sys.modules:
+ raise
def join(self, timeout=None):
if not self.__initialized: