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]

test(router): settle the shared logging worker before recording shadow callbacks (#43847)

devin-ai-integration[bot]b370996b9d2f
diff --git a/tests/unit/test_router_silent_experiment.py b/tests/unit/test_router_silent_experiment.py
index ab65e09e133..722a76fa7ef 100644
--- a/tests/unit/test_router_silent_experiment.py
+++ b/tests/unit/test_router_silent_experiment.py
@@ -9,6 +9,7 @@ import pytest
import litellm
from litellm.integrations.custom_logger import CustomLogger
+from litellm.litellm_core_utils.logging_worker import GLOBAL_LOGGING_WORKER
from litellm.router import Router
from litellm.router import _silent_experiment_kwargs_snapshot
from litellm.router import _silent_experiment_targets
@@ -30,8 +31,20 @@ class _RecordingLogger(CustomLogger):
]
+async def _settle_shared_logging_worker() -> None:
+ try:
+ await GLOBAL_LOGGING_WORKER.flush()
+ finally:
+ await GLOBAL_LOGGING_WORKER.stop()
+
+
@pytest.fixture
def recording_logger():
+ settle_loop: Final = asyncio.new_event_loop()
+ try:
+ settle_loop.run_until_complete(_settle_shared_logging_worker())
+ finally:
+ settle_loop.close()
original_callbacks: Final = litellm.callbacks
logger: Final = _RecordingLogger()
litellm.callbacks = [logger]