mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-09 22:31:41 +00:00
fix(test): add timeout to flush() call to prevent 300s hang in CI
GLOBAL_LOGGING_WORKER.flush() calls queue.join() which blocks until all items are task_done(). In CI with pytest-asyncio, each test gets a fresh event loop so the worker reinitializes its queue - items from a previous test never get task_done(), causing an infinite hang. Fix: wrap flush() with asyncio.wait_for(..., timeout=10.0).
This commit is contained in:
parent
c810f5cd63
commit
d9301c58ae
1 changed files with 7 additions and 2 deletions
|
|
@ -102,9 +102,14 @@ async def test_async_no_duplicate_spend_logs():
|
|||
# Without this, flush() may block on a stale queue from a previous test's loop.
|
||||
await asyncio.sleep(0)
|
||||
|
||||
# Wait for async logging to complete
|
||||
# Wait for async logging to complete. Use a timeout so that if the
|
||||
# worker is on a stale event loop (common in CI), flush() doesn't hang
|
||||
# indefinitely — the queue.join() inside flush() would never resolve.
|
||||
from litellm.litellm_core_utils.logging_worker import GLOBAL_LOGGING_WORKER
|
||||
await GLOBAL_LOGGING_WORKER.flush()
|
||||
try:
|
||||
await asyncio.wait_for(GLOBAL_LOGGING_WORKER.flush(), timeout=10.0)
|
||||
except asyncio.TimeoutError:
|
||||
pass
|
||||
await asyncio.sleep(0.5)
|
||||
|
||||
# Verify that log_success_event was called exactly once for our request
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue