diff --git a/litellm/integrations/langsmith.py b/litellm/integrations/langsmith.py index 033638b90..f44ac5b87 100644 --- a/litellm/integrations/langsmith.py +++ b/litellm/integrations/langsmith.py @@ -68,7 +68,11 @@ class LangsmithLogger(CustomBatchLogger): if _batch_size: self.batch_size = int(_batch_size) self.log_queue: List[LangsmithQueueObject] = [] - asyncio.create_task(self.periodic_flush()) + loop = asyncio.get_event_loop_policy().get_event_loop() + if not loop.is_running(): + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + loop.create_task(self.periodic_flush()) self.flush_lock = asyncio.Lock() super().__init__(**kwargs, flush_lock=self.flush_lock)