fix(test): add asyncio.sleep(0) before flush() to prevent hang in test_async_no_duplicate_spend_logs

This commit is contained in:
Ishaan Jaffer 2026-02-21 13:07:32 -08:00
parent 336ecd6267
commit 6efd2f56a9

View file

@ -96,6 +96,12 @@ async def test_async_no_duplicate_spend_logs():
litellm_call_id=test_request_id,
)
# Yield to the event loop so the _client_async_logging_helper task
# (scheduled via asyncio.create_task in the @client decorator) runs first
# and initializes GLOBAL_LOGGING_WORKER on the current event loop.
# 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
from litellm.litellm_core_utils.logging_worker import GLOBAL_LOGGING_WORKER
await GLOBAL_LOGGING_WORKER.flush()