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(tests): replace asyncio.sleep(1) with event-based wait in metadata callback tests (#21805)
Ishaan Jaff02670582c570
diff --git a/tests/test_litellm/responses/test_metadata_codex_callback.py b/tests/test_litellm/responses/test_metadata_codex_callback.pyindex 21c0c644521..4c4ea764fe8 100644--- a/tests/test_litellm/responses/test_metadata_codex_callback.py+++ b/tests/test_litellm/responses/test_metadata_codex_callback.py@@ -44,11 +44,13 @@ class MetadataCaptureCallback(CustomLogger):def __init__(self):self.captured_kwargs: Optional[dict] = None+ self.event = asyncio.Event()async def async_log_success_event(self, kwargs, response_obj, start_time, end_time):self.captured_kwargs = kwargs+ self.event.set()@pytest.mark.asyncio@@ -104,7 +106,7 @@ async def test_metadata_passed_to_custom_callback_codex_models():metadata=test_metadata,)- await asyncio.sleep(1)+ await asyncio.wait_for(callback.event.wait(), timeout=5.0)assert callback.captured_kwargs is not None, "Callback should have been invoked"@@ -165,7 +167,7 @@ async def test_metadata_passed_via_litellm_metadata_responses_api():litellm_metadata=test_metadata,)- await asyncio.sleep(1)+ await asyncio.wait_for(callback.event.wait(), timeout=5.0)assert callback.captured_kwargs is not None