Repository navigation
Commit d97d137
committed
fix(client): end the read stream when stdout hits EOF on a live server
`stdout_reader` closes the read stream inside `async with read_stream_writer`,
but its `finally` runs `_drain_stdout` first, and before this change that
drain sat in a shielded `while True: await process.stdout.receive()`. When the
server closes stdout without exiting, the drain waits on the still-open pipes
of a live process that will never write again, so the writer is never closed,
the session never sees the end of the stream, and every waiting request waits
forever. A crashed wrapper or a closed fd reproduces it without any mistake
on the caller's side.
Terminate the process before draining unless shutdown already asked for it.
Shutdown keeps its own stop sequence, and the drain keeps its reason to exist
(a server flushing its last output must not block on a full pipe), it just
runs against a process that is now closing its pipes.
That also makes the read side symmetric with `stdin_writer`, which already
closes the read stream on a failed write so the session ends instead of
hanging.1 parent af4c6f4 commit d97d137
2 files changed
Lines changed: 33 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
160 | 164 | | |
161 | 165 | | |
162 | 166 | | |
163 | 167 | | |
164 | 168 | | |
165 | 169 | | |
166 | | - | |
| 170 | + | |
167 | 171 | | |
168 | 172 | | |
169 | 173 | | |
| |||
204 | 208 | | |
205 | 209 | | |
206 | 210 | | |
207 | | - | |
| 211 | + | |
208 | 212 | | |
209 | 213 | | |
210 | 214 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
326 | 349 | | |
327 | 350 | | |
328 | 351 | | |
| |||
723 | 746 | | |
724 | 747 | | |
725 | 748 | | |
| 749 | + | |
| 750 | + | |
726 | 751 | | |
727 | 752 | | |
728 | 753 | | |
| |||
744 | 769 | | |
745 | 770 | | |
746 | 771 | | |
747 | | - | |
| 772 | + | |
748 | 773 | | |
749 | 774 | | |
750 | 775 | | |
| |||
0 commit comments