mirror of
https://github.com/python/cpython.git
synced 2025-08-08 10:58:51 +00:00
[3.12] gh-112826: Fix the threading Module When _thread is Missing _is_main_interpreter() (#112850)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
This commit is contained in:
parent
34e9e20cf2
commit
c0fc88fa2f
3 changed files with 51 additions and 1 deletions
|
@ -37,7 +37,20 @@ _daemon_threads_allowed = _thread.daemon_threads_allowed
|
|||
_allocate_lock = _thread.allocate_lock
|
||||
_set_sentinel = _thread._set_sentinel
|
||||
get_ident = _thread.get_ident
|
||||
_is_main_interpreter = _thread._is_main_interpreter
|
||||
try:
|
||||
_is_main_interpreter = _thread._is_main_interpreter
|
||||
except AttributeError:
|
||||
# See https://github.com/python/cpython/issues/112826.
|
||||
# We can pretend a subinterpreter is the main interpreter for the
|
||||
# sake of _shutdown(), since that only means we do not wait for the
|
||||
# subinterpreter's threads to finish. Instead, they will be stopped
|
||||
# later by the mechanism we use for daemon threads. The likelihood
|
||||
# of this case is small because rarely will the _thread module be
|
||||
# replaced by a module without _is_main_interpreter().
|
||||
# Furthermore, this is all irrelevant in applications
|
||||
# that do not use subinterpreters.
|
||||
def _is_main_interpreter():
|
||||
return True
|
||||
try:
|
||||
get_native_id = _thread.get_native_id
|
||||
_HAVE_THREAD_NATIVE_ID = True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue