Repository navigation
fix(stdio): settle writer close and disconnection - #199
Open
Elon-Jiang wants to merge 1 commit into
Open
Elon-Jiang wants to merge 1 commit into
Elon-Jiang wants to merge 1 commit into
Conversation
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.
Summary
The
StreamWriterreturned bystdio_streams()cannot complete normalwait_closed()calls (_get_close_waiteris missing). If stdout is backpressured when its reader disconnects,drain()never wakes because the protocol ignoresconnection_lost. The Windows stdout adapter also logs write failures but leaves the writer apparently usable.Use asyncio's existing flow-control implementation, add the writer's close waiter, and notify the same protocol when the Windows adapter closes or fails a write. Pending sends now fail on disconnection and normal buffered output can close cleanly. No public signatures, schema, or dependencies change.
Related issues
Found through the public stdio API on main
4fed584775d6a650cd669b63617049e5352297fe. This is separate from subprocess-stdin shutdown (#152) and the original Windows pipe setup report (#3); neither supplies this writer's missing close/error lifecycle.Testing
AttributeError; POSIXdrain()times out under reader closure; the Windows adapter does not report its write error.pytest tests/real_user/test_stdio_writer.py tests/real_user/test_stdio_limits.py tests/real_user/test_stdio_shutdown.py -q: 12 passed.make check: passed (locked dependencies, actual prek checks, ty, deptry).NO_PROXY=localhost,127.0.0.1,::1 no_proxy=localhost,127.0.0.1,::1 make test: 544 passed, 1 skipped (optional Gemini), with one code-generation warning in unchanged code. The per-command loopback override allows the existing native WebSocket tests to bypass this machine's SOCKS proxy.The POSIX tests use real subprocess stdio pipes, including 1 MiB buffered output and closing the actual receiving pipe. The Windows-specific adapter is exercised via the public
stdio_streams()entry point with controlled standard handles on macOS; no native Windows execution is claimed.Docs & screenshots
Expanded the public
stdio_streamsdocstring to describeclose/wait_closedand disconnection errors. No UI changes or schema regeneration.Checklist
AI assistance was used for investigation, implementation and local verification; no human review is claimed.