fix: accurate wipe count on partial failure, remove stray blank line

This commit is contained in:
Ryan Crabbe 2026-02-26 12:36:57 -08:00
parent 0ee8cb5f02
commit 0020e5929d
2 changed files with 4 additions and 3 deletions

View file

@ -15,14 +15,16 @@ from litellm._logging import verbose_proxy_logger
def wipe_directory(directory: str) -> None:
"""Delete all .db files in the directory. Called once before workers fork."""
files = glob.glob(os.path.join(directory, "*.db"))
deleted = 0
for filepath in files:
try:
os.remove(filepath)
deleted += 1
except OSError as e:
verbose_proxy_logger.warning(
f"Failed to delete stale prometheus file {filepath}: {e}"
)
if files:
if deleted:
verbose_proxy_logger.info(
f"Prometheus cleanup: wiped {len(files)} stale .db files from {directory}"
f"Prometheus cleanup: wiped {deleted} stale .db files from {directory}"
)

View file

@ -2045,7 +2045,6 @@ def _schedule_background_health_check_db_save(
)
async def _run_background_health_check():
"""
Periodically run health checks in the background on the endpoints.