gh-116167: Allow disabling the GIL with PYTHON_GIL=0 or -X gil=0#116338
Merged
colesbury merged 11 commits intopython:mainfrom Mar 11, 2024
Merged
gh-116167: Allow disabling the GIL with PYTHON_GIL=0 or -X gil=0#116338colesbury merged 11 commits intopython:mainfrom
PYTHON_GIL=0 or -X gil=0#116338colesbury merged 11 commits intopython:mainfrom
Conversation
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
In free-threaded builds, running with
PYTHON_GIL=0or-X gil=0will now disable the GIL. #116322 and #116329 track follow-up work to re-enable the GIL when loading an incompatible extension, and to disable the GIL by default, respectively.In order to support re-enabling the GIL at runtime, all GIL-related data structures are initialized as usual, and disabling the GIL simply sets a flag at startup that causes
take_gil()anddrop_gil()to return early.With
PYTHON_GIL=0set, I spot-checked a few tests and small programs that don't use threads. They all seem to run fine, and very basic threaded programs work, sometimes. Trying to run the full test suite crashes pretty quickly, intest_asyncio.