[Python] Do not fall back to the GIL on free-threaded Python#22548
Open
guitargeek wants to merge 1 commit into
Open
[Python] Do not fall back to the GIL on free-threaded Python#22548guitargeek wants to merge 1 commit into
guitargeek wants to merge 1 commit into
Conversation
On a free-threaded ("GIL-less") Python build, importing a C extension
module that does not explicitly declare free-threading support makes
CPython re-enable the GIL at runtime and print a warning. Mark both the
CPyCppyy module and the ROOT pythonizations module with
Py_MOD_GIL_NOT_USED via PyUnstable_Module_SetGIL so that importing ROOT
no longer forces the GIL back on.
The calls are guarded by Py_GIL_DISABLED and therefore have no effect on
regular GIL-enabled builds.
Note that this is a declaration of intent, not a guarantee of full
thread-safety: ROOT's interpreter and global state have not yet been
audited for concurrent use, so unsynchronized multithreaded access may
still produce wrong results or crashes. The purpose of the change is to
signal our commitment to supporting free-threaded Python and to
encourage users to run multithreaded workloads and report issues, so
that the remaining thread-safety problems can be surfaced and fixed.
Test Results 22 files 22 suites 3d 15h 54m 0s ⏱️ For more details on these failures, see this check. Results for commit 7ac7cd3. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
On a free-threaded ("GIL-less") Python build, importing a C extension module that does not explicitly declare free-threading support makes CPython re-enable the GIL at runtime and print a warning. Mark both the CPyCppyy module and the ROOT pythonizations module with Py_MOD_GIL_NOT_USED via PyUnstable_Module_SetGIL so that importing ROOT no longer forces the GIL back on.
The calls are guarded by Py_GIL_DISABLED and therefore have no effect on regular GIL-enabled builds.
Note that this is a declaration of intent, not a guarantee of full thread-safety: ROOT's interpreter and global state have not yet been audited for concurrent use, so unsynchronized multithreaded access may still produce wrong results or crashes. The purpose of the change is to signal our commitment to supporting free-threaded Python and to encourage users to run multithreaded workloads and report issues, so that the remaining thread-safety problems can be surfaced and fixed.