From 5f84eb7001c55bae60af64622e288a6a9682f332 Mon Sep 17 00:00:00 2001 From: Alexsander Hamir Date: Wed, 7 Jan 2026 12:38:25 -0800 Subject: [PATCH] Fix: enable_line_profiler() doesn't return a value - handle ImportError properly --- litellm/proxy/common_utils/performance_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/litellm/proxy/common_utils/performance_utils.py b/litellm/proxy/common_utils/performance_utils.py index 987efb82922..f9537f85e2b 100644 --- a/litellm/proxy/common_utils/performance_utils.py +++ b/litellm/proxy/common_utils/performance_utils.py @@ -160,7 +160,9 @@ def wrap_function_with_line_profiler(module: Any, function_name: str) -> bool: Returns: True if wrapping was successful, False otherwise """ - if not enable_line_profiler(): + try: + enable_line_profiler() # May raise ImportError if not available + except ImportError: return False if _line_profiler is None: