Commit 7e091ba
committed
fix: bound uvicorn graceful shutdown so thread.join doesn't abandon it mid-drain
Without timeout_graceful_shutdown, uvicorn's shutdown() waits indefinitely
for open connections to close. The SSE reconnection tests in
test_streamable_http.py can leave streams open at fixture teardown, so
the 5s thread.join times out and abandons the thread mid-shutdown.
On Windows Proactor, the abandoned connection transports still have
pending Overlapped Recv operations when the event loop is torn down.
GC later finds them during an unrelated test, surfacing as
PytestUnraisableExceptionWarning. Previously hidden by subprocess
isolation.
timeout_graceful_shutdown=1 gives uvicorn a bounded window to drain
connections, then cancels remaining tasks via asyncio — transports
unwind through CancelledError instead of being abandoned.1 parent 36991d8 commit 7e091ba
1 file changed
+6
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
50 | 56 | | |
51 | 57 | | |
52 | 58 | | |
| |||
0 commit comments