Repository navigation
🐛 fix(subprocess): stop the backend when a call is interrupted - #332
Merged
gaborbernat merged 2 commits intoOct 27, 2026
Merged
Conversation
Popen.kill() already returns without signalling once the process has exited, so the poll() guard repeated it. The test now asserts the one observable effect, the output thread ending; closed pipes follow from communicate() returning. Name the parametrized cases and mark the new locals Final.
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.

When a frontend call raised while waiting on the backend, for example on
KeyboardInterruptorSystemExitfrom a signal handler, the backend process kept running and its output-collection thread kept the interpreter alive until the backend finished on its own. 🛑 The frontend now stops the backend it started and waits for that thread before the original exception reaches the caller.The cleanup belongs to the frontend's per-call context: on any exit from a call it kills the backend process (a no-op once the process has exited) and joins the thread that drains the backend's pipes. The exception itself propagates unchanged.
Impact
Only the backend process is stopped, not processes it started. If such a child inherits the backend's output pipes and keeps running, the frontend waits for it before the exception reaches the caller; with a child that sleeps 8 seconds, the interrupt surfaced after 8 seconds. Before this change the exception surfaced at once, but the interpreter still waited at exit for both the backend and the child. Stopping a whole process tree stays out of scope.