mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
test(router): filter aiohttp unclosed-session gc noise in test_async_fallbacks
test_async_fallbacks asserts the last three captured log records are the router's fallback messages. Under the litellm_router_testing job (pytest -k router -n 4) many router tests share the module-level in_memory_llm_clients_cache (max 200, ttl 3600s). Older cached OpenAI/Azure clients get evicted while their aiohttp ClientSession is still open, and when the gc reclaims them aiohttp emits "Unclosed client session"/"Unclosed connector" through the asyncio logger. Those records land in caplog mid-test and push the expected router logs out of the last-three window, so the assertion flips to failing non-deterministically. These warnings are async cleanup noise, not router debug logs, so filter them out exactly like the existing leaked-task warnings before asserting order. The assertion on the three router fallback messages is unchanged.
This commit is contained in:
parent
1d4f4a1104
commit
362d2403ea
1 changed files with 5 additions and 1 deletions
|
|
@ -82,7 +82,9 @@ def test_async_fallbacks(caplog):
|
|||
asyncio.run(_make_request())
|
||||
captured_logs = [rec.message for rec in caplog.records]
|
||||
|
||||
# on circle ci the captured logs get some async task exception logs - filter them out "Task exception was never retrieved"
|
||||
# on circle ci the captured logs get async cleanup noise from the gc (leaked
|
||||
# task warnings, plus aiohttp "Unclosed client session"/"Unclosed connector"
|
||||
# warnings from cached clients other router tests evicted) - filter it out
|
||||
captured_logs = [
|
||||
log
|
||||
for log in captured_logs
|
||||
|
|
@ -90,6 +92,8 @@ def test_async_fallbacks(caplog):
|
|||
and "Task was destroyed but it is pending" not in log
|
||||
and "get_available_deployment" not in log
|
||||
and "in the Langfuse queue" not in log
|
||||
and "Unclosed client session" not in log
|
||||
and "Unclosed connector" not in log
|
||||
]
|
||||
|
||||
print("\n Captured caplog records - ", captured_logs)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue