[3.12] gh-112826: Fix the threading Module When _thread is Missing _is_main_interpreter()#112850
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_thread._is_main_interpreter()was added (and aliased asthreading._is_main_interpreter()) after the 3.12.0 release, in gh-110707 (a backport of gh-112661). However, that change did not accommodate cases where users replace the_threadmodule with a custom version that doesn't have_is_main_interpreter()defined (e.g. gevent).This change fixes that by falling back to a dummy
_is_main_interpreter()that always says "yes". That case is unlikely and the consequences of saying a subinterpreter is the main interpreter, relative to `threading._shutdown(), are almost zero.(We are fixing this in 3.12 only because it is a regression from the already released 3.12.0. In 3.13 (main) we will only have the note in "What's New".)
📚 Documentation preview 📚: https://cpython-previews--112850.org.readthedocs.build/