Skip to content

Commit efe0631

Browse files
committed
fix: suppress Windows ProactorBasePipeTransport teardown warning
On Windows Python 3.13, the ProactorBasePipeTransport.__del__ fires during GC after the threaded uvicorn server shuts down, raising a PytestUnraisableExceptionWarning due to filterwarnings=['error']. Force a GC collection with warnings suppressed so the transport finalizer runs before pytest's unraisable-exception hook can catch it.
1 parent ff4239d commit efe0631

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/shared/test_streamable_http.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,6 +1570,14 @@ def _run() -> None:
15701570
server_instance.should_exit = True
15711571
thread.join(timeout=5)
15721572

1573+
# Force GC and suppress Windows ProactorBasePipeTransport.__del__ warnings
1574+
# that surface when the event loop is torn down in a thread.
1575+
import gc
1576+
1577+
with warnings.catch_warnings():
1578+
warnings.filterwarnings("ignore", category=pytest.PytestUnraisableExceptionWarning)
1579+
gc.collect()
1580+
15731581

15741582
@pytest.mark.anyio
15751583
async def test_streamablehttp_request_context_propagation(context_aware_server: None, basic_server_url: str) -> None:

0 commit comments

Comments
 (0)