From cdaff4f0e3d9fd261f5b38bc02fe09a377bf45d8 Mon Sep 17 00:00:00 2001 From: Ryan Crabbe Date: Wed, 25 Feb 2026 17:43:45 -0800 Subject: [PATCH] wip redundant code --- litellm/proxy/proxy_cli.py | 27 ++++++++++++--------------- litellm/proxy/proxy_server.py | 4 ---- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/litellm/proxy/proxy_cli.py b/litellm/proxy/proxy_cli.py index 1be4931aeef..480f00c3562 100644 --- a/litellm/proxy/proxy_cli.py +++ b/litellm/proxy/proxy_cli.py @@ -322,9 +322,6 @@ class ProxyInitializationHelpers: """ Auto-create PROMETHEUS_MULTIPROC_DIR when running with multiple workers and prometheus is configured as a callback. - - If the env var is already set by the user, just ensure the directory exists. - Otherwise, create a temp directory and set the env var. """ import tempfile @@ -341,25 +338,25 @@ class ProxyInitializationHelpers: from litellm.proxy.prometheus_cleanup import wipe_directory - existing_dir = os.environ.get( - "PROMETHEUS_MULTIPROC_DIR" - ) or os.environ.get("prometheus_multiproc_dir") - if existing_dir: - os.makedirs(existing_dir, exist_ok=True) - wipe_directory(existing_dir) - print( # noqa - f"LiteLLM: Using existing PROMETHEUS_MULTIPROC_DIR={existing_dir}" - ) - return + multiproc_dir = ( + os.environ.get("PROMETHEUS_MULTIPROC_DIR") + or os.environ.get("prometheus_multiproc_dir") + ) + auto_created = not multiproc_dir + + if not multiproc_dir: + multiproc_dir = os.path.join( + tempfile.gettempdir(), "litellm_prometheus_multiproc" + ) multiproc_dir = os.path.join( tempfile.gettempdir(), "litellm_prometheus_multiproc" ) os.makedirs(multiproc_dir, exist_ok=True) wipe_directory(multiproc_dir) - os.environ["PROMETHEUS_MULTIPROC_DIR"] = multiproc_dir + action = "Auto-created" if auto_created else "Use existing" print( # noqa - f"LiteLLM: Auto-created PROMETHEUS_MULTIPROC_DIR={multiproc_dir}" + f"LiteLLM {action}: Auto-created PROMETHEUS_MULTIPROC_DIR={multiproc_dir}" ) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index e950a1f9909..26728eabf78 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -2064,10 +2064,6 @@ def _schedule_background_health_check_db_save( async def _periodic_prometheus_cleanup(): """ Periodically mark dead worker PIDs in the prometheus multiproc directory. - - Uses mark_process_dead() which only removes gauge_live* files, preserving - counter/histogram data for correct aggregation. First run is 1 hour after - startup (startup wipe handles stale files), then every hour thereafter. """ from litellm.proxy.prometheus_cleanup import mark_dead_pids