fix finalizing and atexit timing#6626
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 📝 WalkthroughWalkthroughThe interpreter finalization sequence is restructured to dynamically import the threading module and call Changes
Sequence DiagramsequenceDiagram
participant VM as Virtual Machine
participant Threading as Threading Module
participant Atexit as Atexit System
VM->>Threading: Attempt dynamic import
alt Import Successful
VM->>Threading: Call threading._shutdown()
Threading-->>VM: Shutdown complete
else Import Failed
VM-->>VM: Continue
end
VM->>VM: Set finalizing flag = true
VM->>Atexit: Run atexit functions
Atexit-->>VM: Cleanup complete
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly Related PRs
Suggested Reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Sorry, something went wrong.
|
You may want to take a look in |
Sorry, something went wrong.
|
@fanninpm they are downgraded to expectedFailure (@terryluan12 thanks!) |
Sorry, something went wrong.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@crates/vm/src/vm/mod.rs`:
- Around line 552-562: The finalizing flag is set before calling
atexit::_run_exitfuncs, causing run_unraisable to early-return and suppress
atexit handler exceptions; either move the store to state.finalizing to after
atexit::_run_exitfuncs(vm) so finalization suppression happens post-atexit, or
add a small atexit bypass: introduce an atexit-running marker on VM state (e.g.,
vm.state.atexit_running) set around atexit::_run_exitfuncs and change
run_unraisable to allow reporting when that marker is true (while still
suppressing in other finalization contexts). Ensure references are to
run_unraisable, atexit::_run_exitfuncs, and state.finalizing (or the new
state.atexit_running) so reviewers can find and apply the change.
Sorry, something went wrong.
11c9b0e
into
RustPython:main
Jan 17, 2026
That's better than nothing! |
Sorry, something went wrong.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.