feat(proxy): add --timeout_worker_healthcheck flag for uvicorn worker triage - #26622
Conversation
Greptile SummaryThis PR adds a Confidence Score: 5/5PR is safe to merge — changes are additive, guarded by a runtime version check, and existing behaviour is unaffected. No P0 or P1 issues found. The No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/proxy/proxy_cli.py | Adds timeout_worker_healthcheck parameter to _get_default_unvicorn_init_args, a new CLI option, and a running_uvicorn guard that passes None when gunicorn/hypercorn is active — cleanly preventing spurious version warnings. |
| tests/test_litellm/proxy/test_proxy_cli.py | Adds a happy-path stub test for timeout_worker_healthcheck in _get_default_unvicorn_init_args and a new CLI roundtrip test; updates test_keepalive_timeout_flag with the new kwarg — the warning/else branch remains uncovered. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[run_server CLI invoked] --> B{--run_gunicorn\nor --run_hypercorn?}
B -- Yes --> C[running_uvicorn = False\ntimeout_worker_healthcheck = None\npassed to helper]
B -- No --> D[running_uvicorn = True\ntimeout_worker_healthcheck = value\npassed to helper]
C --> E[_get_default_unvicorn_init_args\ntimeout_worker_healthcheck is None\nblock skipped entirely]
D --> F{timeout_worker_healthcheck\nis not None?}
F -- No --> G[uvicorn_args returned\nwithout the kwarg]
F -- Yes --> H{timeout_worker_healthcheck\nin uvicorn.Config.__init__\nsignature?}
H -- Yes\nuvicorn >= 0.37.0 --> I[uvicorn_args includes\ntimeout_worker_healthcheck]
H -- No\nuvicorn < 0.37.0 --> J[Print yellow warning\nkwarg dropped from args]
I --> K[uvicorn.run called\nwith timeout_worker_healthcheck]
G --> K
J --> K
Reviews (3): Last reviewed commit: "feat(proxy): add --timeout_worker_health..." | Re-trigger Greptile
… triage Adds a CLI flag (`--timeout_worker_healthcheck`, env `TIMEOUT_WORKER_HEALTHCHECK`) that forwards to uvicorn's `timeout_worker_healthcheck` Config kwarg (added in uvicorn 0.37.0). Lets operators raise the supervisor's worker-ping timeout above the default 5s when triaging workers being killed and respawned under load. The helper introspects `uvicorn.Config.__init__` and only sets the kwarg if supported, otherwise prints a warning - so the existing uvicorn>=0.32.1,<1.0.0 floor pin is unaffected. Gunicorn and Hypercorn paths are unchanged (the uvicorn supervisor isn't running there); the value is also not passed to the helper at all on those paths so the "uvicorn too old" warning never fires spuriously.
12774af to
84527b0
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
44dece1
into
litellm_internal_staging
…ker-healthcheck-flag feat(proxy): add --timeout_worker_healthcheck flag for uvicorn worker triage
Summary
--timeout_worker_healthcheck(envTIMEOUT_WORKER_HEALTHCHECK) that forwards to uvicorn'stimeout_worker_healthcheckConfig kwarg (added in uvicorn 0.37.0, default 5s).uvicorn.Config.__init__and only sets the kwarg if supported; otherwise prints a yellow warning naming the installed uvicorn version. The existinguvicorn>=0.32.1,<1.0.0floor pin is unchanged.--run_gunicornor--run_hypercorn, the kwarg is not passed to the helper at all so the "uvicorn too old" warning never fires spuriously.Screenshots
Test plan
tests/test_litellm/proxy/test_proxy_cli.py::TestProxyInitializationHelpers::test_get_default_unvicorn_init_args— extended to cover the supported branch (stubsuvicorn.Configso it's stable across uvicorn version bumps in CI)tests/test_litellm/proxy/test_proxy_cli.py::TestProxyInitializationHelpers::test_timeout_worker_healthcheck_flag— new CLI roundtrip test mirroringtest_keepalive_timeout_flagtest_keepalive_timeout_flagupdated for the new helper kwarg signature (still passes)tests/test_litellm/proxy/test_proxy_cli.pyfile locally — 26 passeduvicorn>=0.37install in the venv:ProxyInitializationHelpers._get_default_unvicorn_init_args(host=..., port=..., timeout_worker_healthcheck=30)returns the kwarg in the dict, anduvicorn.Config(**args)builds withcfg.timeout_worker_healthcheck == 30--timeout-worker-healthcheck 30the same SIGSTOP'd worker survived 30s before being killed