Repository navigation
Fix runtime shutdown before interpreter finalization - #2120
Open
brianstrauch wants to merge 3 commits into
Open
brianstrauch wants to merge 3 commits into
brianstrauch wants to merge 3 commits into
Conversation
Contributor
|
Cloud doesn't seem to allow whatever RPC you are using for the test and fails. |
VegetarianOrc
requested changes
Nov 17, 2026
VegetarianOrc
left a comment
Contributor
There was a problem hiding this comment.
I think let's also add some warnings to the docstring on the Python side Runtime class. We've already got some notes about runtimes not working across forks, but we should expand it to warn against this leak. Something akin to
Creating a runtime before forking can retain inherited native memory and file
descriptors in the child until it exits, even after the inherited runtime is
garbage collected.
VegetarianOrc
force-pushed
the
fix/runtime-interpreter-shutdown
branch
from
November 19, 2026 03:33
dce72e2 to
8820f0d
Compare
This branch has not been deployed
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.
Short-lived clients can complete an awaited RPC while the Rust callback delivering its result is still active. If Python finalizes before that callback releases its thread state, the process can crash or hang.
Register an
atexithook that shuts down live native runtimes before interpreter finalization, releasing the GIL while joining their threads. Guard access to stopped runtimes and avoid joining runtimes inherited across a fork. Add subprocess regression tests for pending log callbacks with one or multiple runtimes and for an RPC completion callback that remains active after Python receives its result.Addresses #300.
Related CI job: ai-integrations.
Validation on CPython 3.13.13, macOS ARM64:
poe formatpoe build-developpoe bridge-lintpoe test -s tests/bridge/test_runtime.py tests/test_runtime.py -n 2— 18 passed, including server-dependent tests.Full
poe lintdoes not pass locally: mypy reports four errors in unchanged generated gRPC bindings, reproduced on a cleanmaincheckout. The full mypy and docstring commands also inspect unrelated local benchmark files underbuild/and report errors there.