Shut down asyncgens in routing tests to silence cleanup warnings (PR #5711)
Round 18 reviewers (and earlier) noted CI noise from the routing test helper: `_drive(coro)` ran a fresh event loop but never closed it or called `shutdown_asyncgens`, so the MockTransport-backed httpx async generators in the providers were finalised by GC in a later task and emitted "Response.aiter_text.aclose was never awaited" / "Task was destroyed but it is pending" warnings. Explicitly close the loop after `run_until_complete`, running `shutdown_asyncgens` first so the iterators finalise in this task. Tests still pass and the warnings are gone.
This commit is contained in:
parent
0be1e09421
commit
07831d4c0c
1 changed files with 12 additions and 1 deletions
|
|
@ -31,7 +31,18 @@ from core.inference.external_provider import ExternalProviderClient
|
|||
|
||||
|
||||
def _drive(coro):
|
||||
return asyncio.new_event_loop().run_until_complete(coro)
|
||||
# Explicit loop lifecycle + asyncgen shutdown so the httpx /
|
||||
# MockTransport-backed async generators in the providers are
|
||||
# finalised in this task instead of being collected later (which
|
||||
# triggers the "aiter_text aclose was never awaited" warning the
|
||||
# reviewer round noticed).
|
||||
loop = asyncio.new_event_loop()
|
||||
try:
|
||||
result = loop.run_until_complete(coro)
|
||||
loop.run_until_complete(loop.shutdown_asyncgens())
|
||||
return result
|
||||
finally:
|
||||
loop.close()
|
||||
|
||||
|
||||
def _install_mock(monkeypatch, *, sse_payload: bytes | None = None) -> dict:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue