GeezerVison is showing github.com — clear_after_fork by youknowone · Pull Request #6933 · RustPython/RustPython
Conversation
youknowone
commented
Feb 1, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary by CodeRabbit
- Bug Fixes
- Improved process fork behavior to properly reset signal state and internal synchronization mechanisms in child processes, preventing stale parent state from affecting child process execution.
✏️ Tip: You can customize this high-level summary in your review settings.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Feb 1, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
📝 Walkthrough
Walkthrough
Adds post-fork cleanup routines for signal state, wakeup file descriptors, and weakref locks. These functions reset inherited parent state in child processes before Python code execution, preventing stale parent signals and locks from interfering with child process behavior.
Changes
| Cohort / File(s) |
Summary |
Signal state cleanup crates/vm/src/signal.rs, crates/vm/src/stdlib/signal.rs |
Added UNIX-only functions to reset global signal state (clear_after_fork()) and wakeup fd state (clear_wakeup_fd_after_fork()) after fork operations. |
Weakref lock cleanup crates/vm/src/object/core.rs |
Added UNIX-only functions to reset weakref stripe locks (reset_all_after_fork()) and a public wrapper (reset_weakref_locks_after_fork()) guarded by threading configuration. |
Post-fork orchestration crates/vm/src/stdlib/posix.rs |
Integrated cleanup calls into py_os_after_fork_child() to invoke signal, wakeup fd, and weakref lock resets before Python code runs in child process. |
Sequence Diagram
sequenceDiagram
participant Fork Process
participant Child Init as py_os_after_fork_child()
participant Signal Module
participant Signal FD Module
participant Weakref Module
Fork Process->>Child Init: fork() → child process starts
Child Init->>Signal Module: clear_after_fork()
Signal Module->>Signal Module: reset ANY_TRIGGERED & TRIGGERS
Signal Module-->>Child Init: ✓ signal state cleared
Child Init->>Signal FD Module: clear_wakeup_fd_after_fork()
Signal FD Module->>Signal FD Module: reset WAKEUP to INVALID_WAKEUP
Signal FD Module-->>Child Init: ✓ wakeup fd cleared
Child Init->>Weakref Module: reset_weakref_locks_after_fork()
Weakref Module->>Weakref Module: reset all stripe locks
Weakref Module-->>Child Init: ✓ weakref locks cleared
Child Init->>Child Init: run after_fork_child(vm)
Child Init-->>Fork Process: child initialized & ready
Loading
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Poem
🐰 A fork in the road, the process did split,
Locks and signals left in a bit of a fit!
Reset, reset, the rabbit did say,
Clear state before Python runs its way! 🔄
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
| Check name |
Status |
Explanation |
| Description Check |
✅ Passed |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
✅ Passed |
The title 'clear_after_fork' directly matches the primary objective of the changes: adding fork-safe cleanup functions to reset global state (signals, weakref locks, wakeup FDs) after process forking. |
| Docstring Coverage |
✅ Passed |
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
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.
❤️ Share
Comment @coderabbitai help to get the list of available commands and usage tips.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Feb 17, 2026
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|