Skip to content

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]

fix(tests): drain the logging worker queue between MCP tests

Devin AI54ea379c91ab
diff --git a/tests/mcp_tests/conftest.py b/tests/mcp_tests/conftest.py
index d1dc3ec7216..e46c03b5498 100644
--- a/tests/mcp_tests/conftest.py
+++ b/tests/mcp_tests/conftest.py
@@ -42,6 +42,22 @@ def setup_and_teardown():
asyncio.set_event_loop(None) # Remove the reference to the loop
[email protected](scope="function", autouse=True)
+async def drain_logging_worker():
+ """
+ The logging queue is bound to the running loop, so anything left queued when a test's loop
+ goes away is carried onto the next test's loop and fires against its callbacks.
+ """
+ from litellm.litellm_core_utils.logging_worker import GLOBAL_LOGGING_WORKER
+
+ yield
+
+ try:
+ await asyncio.wait_for(GLOBAL_LOGGING_WORKER.clear_queue(), timeout=10)
+ except asyncio.TimeoutError:
+ pass
+
+
def pytest_collection_modifyitems(config, items):
# Separate tests in 'test_amazing_proxy_custom_logger.py' and other tests
custom_logger_tests = [