From 7c42659a9869dec7490a78bd33a1fbed439a0f38 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Tue, 5 Aug 2025 09:58:57 -0700 Subject: [PATCH] =?UTF-8?q?Revert=20"Fix:=20Langfuse=20reporting=20"client?= =?UTF-8?q?=20closed"=20error=20due=20to=20httpx=20client=20TTL=E2=80=A6"?= =?UTF-8?q?=20(#13291)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 1c6be9bdadbeac3ae66bac096e281bc305cd6b5b. --- .../integrations/langfuse/langfuse_handler.py | 48 ++----------------- 1 file changed, 3 insertions(+), 45 deletions(-) diff --git a/litellm/integrations/langfuse/langfuse_handler.py b/litellm/integrations/langfuse/langfuse_handler.py index 56ed01563b..f9d27f6cf0 100644 --- a/litellm/integrations/langfuse/langfuse_handler.py +++ b/litellm/integrations/langfuse/langfuse_handler.py @@ -12,10 +12,6 @@ from litellm.litellm_core_utils.litellm_logging import StandardCallbackDynamicPa from .langfuse import LangFuseLogger, LangfuseLoggingConfig -from httpx._client import ClientState - -from litellm._logging import verbose_logger - if TYPE_CHECKING: from litellm.litellm_core_utils.litellm_logging import DynamicLoggingCache else: @@ -64,17 +60,7 @@ class LangFuseHandler: ) # if not cached, create a new langfuse logger and cache it - if temp_langfuse_logger is None or not LangFuseHandler._logger_httpx_client_is_unclosed(temp_langfuse_logger): - # if the cached logger is closed, remove it from cache - if temp_langfuse_logger is not None: - key = in_memory_dynamic_logger_cache.get_cache_key( - args={**credentials_dict, "service_name": "langfuse"} - ) - in_memory_dynamic_logger_cache.cache._remove_key(key) - verbose_logger.warning( - "LangFuseLogger was found in cache but it was closed. Removing it from cache and creating a new one." - ) - + if temp_langfuse_logger is None: temp_langfuse_logger = ( LangFuseHandler._create_langfuse_logger_from_credentials( credentials=credentials_dict, @@ -97,7 +83,7 @@ class LangFuseHandler: If no Global LangfuseLogger is set, it will check in_memory_dynamic_logger_cache for a cached LangFuseLogger This function is used to return the globalLangfuseLogger if it exists, otherwise it will check in_memory_dynamic_logger_cache for a cached LangFuseLogger """ - if globalLangfuseLogger is not None and LangFuseHandler._logger_httpx_client_is_unclosed(globalLangfuseLogger): + if globalLangfuseLogger is not None: return globalLangfuseLogger credentials_dict: Dict[ @@ -109,17 +95,7 @@ class LangFuseHandler: credentials=credentials_dict, service_name="langfuse", ) - if globalLangfuseLogger is None or not LangFuseHandler._logger_httpx_client_is_unclosed(globalLangfuseLogger): - # if the cached logger is closed, remove it from cache - if globalLangfuseLogger is not None: - key = in_memory_dynamic_logger_cache.get_cache_key( - args={**credentials_dict, "service_name": "langfuse"} - ) - in_memory_dynamic_logger_cache.cache._remove_key(key) - verbose_logger.warning( - "LangFuseLogger was found in cache but it was closed. Removing it from cache and creating a new one." - ) - + if globalLangfuseLogger is None: globalLangfuseLogger = ( LangFuseHandler._create_langfuse_logger_from_credentials( credentials=credentials_dict, @@ -192,21 +168,3 @@ class LangFuseHandler: ): return True return False - - @staticmethod - def _logger_httpx_client_is_unclosed( - logger: LangFuseLogger, - ) -> bool: - """ - This function checks if the httpx client used by the logger is not closed. - - Args: - logger (LangFuseLogger): The LangFuseLogger instance to check. - - Returns: - bool: True if the httpx client is not closed, False otherwise. - """ - verbose_logger.debug(f"LangFuseLogger's httpx client state: {logger.Langfuse.httpx_client._state}") - if logger is not None and logger.Langfuse.httpx_client._state != ClientState.CLOSED: - return True - return False