[NOGIL] Declare cimpl free-threaded on CPython 3.14t#2312
Open
Honglei (honglei) wants to merge 2 commits into
Open
[NOGIL] Declare cimpl free-threaded on CPython 3.14t#2312Honglei (honglei) wants to merge 2 commits into
Honglei (honglei) wants to merge 2 commits into
Conversation
Declare the single-phase cimpl module safe without the GIL and protect the ShareConsumer Messages type cache during concurrent initialization. Add adaptive-GIL assertions plus independent, shared-client, and real-broker concurrency coverage.
Honglei (honglei)
requested review from
a team and
Matthew Seal (MSeal)
as code owners
July 21, 2026 08:54
|
🎉 All Contributor License Agreements have been signed. Ready to merge. |
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.
Relates to #2092
What
Declare the CPython 3.14t
cimplextension as free-threaded and protect thelazy
ShareConsumerMessagestype cache when the GIL is disabled.This is based on
dev_thread_free_support, which already provides the 3.14tbuild and test dependency preparation.
Changes
PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED)for free-threadedbuilds.
Messagestype initialization withPyMutexon free-threaded builds.
kafka_clusterfixture to covershared AdminClient, Producer, and Consumer operations.
regression suite. The full suite still reports warnings when optional
third-party extensions, such as
fastavro, re-enable the GIL.Validation
Validated on CPython 3.14.6 free-threading at
/opt/python314ton 10.2:3 passed, 1 skippedwithout a broker.4 passedagainst127.0.0.1:19092before wiringthe test into the project integration fixture.
kafka_clusterintegration test against the same broker:1 passed in 1.42swithPYTHON_GIL=0.108 passed.pip check: no broken requirements.messages, zero failures, and no leftover temporary topics.
The integration test is run in a separate
PYTHON_GIL=0process because thefull test process imports optional extensions such as
fastavrothat canre-enable the GIL. The existing source verification job already prepares the
Kafka artifact used by the
kafka_clusterfixture.Scope
This change does not claim concurrent
closewhile another thread is stillcalling
pollorconsume. Callers must stop worker threads before closing ashared client.