mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-02 02:11:58 +00:00
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:
parent
6bc17f98d7
commit
b370996b9d
1 changed files with 13 additions and 0 deletions
|
|
@ -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]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue