mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
#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.
This commit is contained in:
parent
2aae1d92eb
commit
d7a265129c
3 changed files with 41 additions and 7 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue