The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(test): add asyncio.sleep(0) before flush() to prevent hang in test_async_no_duplicate_spend_logs (#21813)
Ishaan Jaff8483477512ef
diff --git a/tests/test_litellm/responses/test_no_duplicate_spend_logs.py b/tests/test_litellm/responses/test_no_duplicate_spend_logs.pyindex 7c0d6c15d6d..f3183624058 100644--- a/tests/test_litellm/responses/test_no_duplicate_spend_logs.py+++ b/tests/test_litellm/responses/test_no_duplicate_spend_logs.py@@ -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 completefrom litellm.litellm_core_utils.logging_worker import GLOBAL_LOGGING_WORKERawait GLOBAL_LOGGING_WORKER.flush()