mirror of
https://github.com/python/cpython.git
synced 2025-10-07 15:42:02 +00:00
bpo-31370: Remove support for threads-less builds (#3385)
* Remove Setup.config * Always define WITH_THREAD for compatibility.
This commit is contained in:
parent
1f06a680de
commit
a6a4dc816d
135 changed files with 2472 additions and 4377 deletions
|
@ -990,38 +990,12 @@ class Thread:
|
|||
|
||||
def _delete(self):
|
||||
"Remove current thread from the dict of currently running threads."
|
||||
|
||||
# Notes about running with _dummy_thread:
|
||||
#
|
||||
# Must take care to not raise an exception if _dummy_thread is being
|
||||
# used (and thus this module is being used as an instance of
|
||||
# dummy_threading). _dummy_thread.get_ident() always returns 1 since
|
||||
# there is only one thread if _dummy_thread is being used. Thus
|
||||
# len(_active) is always <= 1 here, and any Thread instance created
|
||||
# overwrites the (if any) thread currently registered in _active.
|
||||
#
|
||||
# An instance of _MainThread is always created by 'threading'. This
|
||||
# gets overwritten the instant an instance of Thread is created; both
|
||||
# threads return 1 from _dummy_thread.get_ident() and thus have the
|
||||
# same key in the dict. So when the _MainThread instance created by
|
||||
# 'threading' tries to clean itself up when atexit calls this method
|
||||
# it gets a KeyError if another Thread instance was created.
|
||||
#
|
||||
# This all means that KeyError from trying to delete something from
|
||||
# _active if dummy_threading is being used is a red herring. But
|
||||
# since it isn't if dummy_threading is *not* being used then don't
|
||||
# hide the exception.
|
||||
|
||||
try:
|
||||
with _active_limbo_lock:
|
||||
del _active[get_ident()]
|
||||
# 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
|
||||
# current_thread()), and would block.
|
||||
except KeyError:
|
||||
if 'dummy_threading' not in _sys.modules:
|
||||
raise
|
||||
with _active_limbo_lock:
|
||||
del _active[get_ident()]
|
||||
# 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
|
||||
# current_thread()), and would block.
|
||||
|
||||
def join(self, timeout=None):
|
||||
"""Wait until the thread terminates.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue