From 57f1d436e1b3aa99500767a47e6412f15e35b11c Mon Sep 17 00:00:00 2001 From: B-Step62 Date: Thu, 20 Mar 2025 02:06:34 +0900 Subject: [PATCH] clean up Signed-off-by: B-Step62 --- litellm/litellm_core_utils/litellm_logging.py | 9 +-------- litellm/litellm_core_utils/streaming_handler.py | 9 ++------- litellm/responses/streaming_iterator.py | 3 +-- litellm/utils.py | 8 +------- 4 files changed, 5 insertions(+), 24 deletions(-) diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py index e7c34d0ede..53fb33dcbb 100644 --- a/litellm/litellm_core_utils/litellm_logging.py +++ b/litellm/litellm_core_utils/litellm_logging.py @@ -2264,14 +2264,7 @@ class Logging(LiteLLMLoggingBaseClass): if self._should_run_sync_callbacks_for_async_calls() is False: return - executor.submit( - self.success_handler, - result, - start_time, - end_time, - # NB: Since we already run this in a TPE, the handler itself can run sync - synchronous=True, - ) + self.success_handler(result, start_time, end_time) def _should_run_sync_callbacks_for_async_calls(self) -> bool: """ diff --git a/litellm/litellm_core_utils/streaming_handler.py b/litellm/litellm_core_utils/streaming_handler.py index c994018b9d..ae1a9fc66c 100644 --- a/litellm/litellm_core_utils/streaming_handler.py +++ b/litellm/litellm_core_utils/streaming_handler.py @@ -1810,15 +1810,10 @@ class CustomStreamWrapper: ) if litellm.sync_logging: await self.logging_obj.async_success_handler(**logging_params) - self.logging_obj.success_handler(**logging_params, synchronous=True) else: asyncio.create_task(self.logging_obj.async_success_handler(**logging_params)) - executor.submit( - self.logging_obj.success_handler, - **logging_params, - # NB: We already run this in a TPE so the handler itself should run sync - synchronous=True, - ) + + self.logging_obj.success_handler(**logging_params) raise StopAsyncIteration # Re-raise StopIteration else: diff --git a/litellm/responses/streaming_iterator.py b/litellm/responses/streaming_iterator.py index c016e71e7e..804f6fce6a 100644 --- a/litellm/responses/streaming_iterator.py +++ b/litellm/responses/streaming_iterator.py @@ -140,8 +140,7 @@ class ResponsesAPIStreamingIterator(BaseResponsesAPIStreamingIterator): ) ) - executor.submit( - self.logging_obj.success_handler, + self.logging_obj.success_handler( result=self.completed_response, cache_hit=None, start_time=self.start_time, diff --git a/litellm/utils.py b/litellm/utils.py index b923c0e036..2394e031b2 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -1161,13 +1161,7 @@ def client(original_function): # noqa: PLR0915 # LOG SUCCESS - handle streaming success logging in the _next_ object, remove `handle_success` once it's deprecated verbose_logger.info("Wrapper: Completed Call, calling success_handler") - if litellm.sync_logging: - logging_obj.success_handler(result, start_time, end_time) - else: - executor.submit( - # NB: We already run this in a TPE so the handler itself should run sync - logging_obj.success_handler, result, start_time, end_time, synchronous=True, - ) + logging_obj.success_handler(result, start_time, end_time) # RETURN RESULT update_response_metadata(