Repository navigation
Make backend shutdown safe on Python 3.13 and report a stuck backend - #39
Merged
Merged
Conversation
- The stdin pump stops reading once it has delivered `quit` (#3). A read still in flight when the interpreter shuts down holds stdin's buffer lock; Python 3.13 parks that thread forever and closing stdin at exit aborts the process. - backend_exited is reported when the backend process exits, if its output has not closed within a second, with stdio_open: true (#35). In the packaged layout the interpreter behind the venv launcher can keep the pipes open long after the launcher has gone. Reported once, whichever of the spawn error, exit and close comes first. - After the Windows backstop's taskkill, a backend_stuck message (pid, kill status) reports a tree whose output is still open 3 s later.
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.
#3 — SIGABRT at exit on Python 3.13. The stdin pump kept calling
readline()after deliveringquit. If that read returned while the interpreter was finalizing, 3.13 parks the thread forever holding stdin's buffer lock, and closing stdin aborts the process. The pump now stops reading once it has queued a{"type": "quit"}line, so no read is in flight at shutdown. A cheap substring check runs first, so other lines are not parsed twice. Tests check that nothing afterquitis read, and thatquitinside a payload doesn't stop the pump. I couldn't reproduce the abort itself: it is timing-dependent and was only seen on Linux CI.#35 — the backend's exit was reported only when its pipes closed.
backend_exitedis now also sent on the process'sexitevent, ifclosehasn't followed within 1 s, withstdio_open: true. It is sent once, for whichever of spawn error, exit and close comes first.taskkill, its exit status is read. If the backend's output is still open 3 s later, abackend_stuckmessage is sent with the pid and the kill status.renderer/protocol.ts.Two limits:
taskkill /Ton its pid can't reach the interpreter. That needs the backend to report its real pid inready; left for a follow-up.Typecheck, 180 unit tests (1 skipped on Windows) and 132 pytest tests pass locally.
Closes #3, closes #35.