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

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

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(router): always stop the shared logging worker after settling it

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
devin-ai-integration[bot] 2026-09-30 04:44:43 -07:00 • committed by GitHub
parent 6bc17f98d7
commit b370996b9d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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]