litellm/tests/test_litellm/proxy/shutdown
Yucheng He 55152cfc2b fix(proxy): record aborted outcome when spend-log cleanup is cancelled at shutdown
cleanup_old_spend_logs only caught Exception, so a run cut short by
CancelledError recorded no outcome and logged nothing. Under uvicorn the
job was never cancelled at all: uvicorn re-raises the captured SIGTERM as
soon as the lifespan shutdown returns, before asyncio cancels outstanding
tasks, so an in-flight scheduler job simply died with the process.

The cleanup now handles CancelledError by logging elapsed time, rows
deleted and batch count at error level, recording outcome="aborted", and
re-raising. The lifespan shutdown stops the scheduler and awaits the jobs
it cancels while the database is still connected, so that handler runs
under uvicorn too, and the pod lock is released instead of orphaned.

Resolves LIT-6990
2026-09-15 01:54:06 -07:00
..
test_graceful_shutdown_manager.py feat(proxy): native /health/drain preStop hook for graceful shutdown (#29439) 2026-06-02 16:30:44 -07:00
test_scheduled_jobs.py fix(proxy): record aborted outcome when spend-log cleanup is cancelled at shutdown 2026-09-15 01:54:06 -07:00