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

This commit is contained in:
Ishaan Jaff 2026-02-21 13:09:36 -08:00 committed by GitHub
parent 0a0768b3df
commit 8483477512
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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()