UvicornWorker: respect the gunicorn graceful shutdown timeout
Summary
This change propagates Gunicorn's graceful_timeout parameter to Uvicorn's timeout_graceful_shutdown configuration when running Uvicorn as a Gunicorn worker process.
Checklist
- [x] I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
- Not sure if a test is necessary here? In any case it looks like
UvicornWorkerdoesn't have any tests currently. - [x] I've updated the documentation accordingly.
I don't think they are equivalent.
@Kludex what's the difference?
Gunicorn: https://docs.gunicorn.org/en/stable/signals.html#master-process
TERM: Graceful shutdown. Waits for workers to finish their current requests up to the graceful_timeout.
graceful_timeoutAfter receiving a restart signal, workers have this much time to finish serving requests. Workers still alive after the timeout (starting from the receipt of the restart signal) are force killed.
Uvicorn: https://www.uvicorn.org/settings/#timeouts
--timeout-graceful-shutdown
- Maximum number of seconds to wait for graceful shutdown. After this timeout, the server will start terminating requests.
I think the details are on the PR that introduced it. But I think it's because the one from Uvicorn is related to the ASGI event (shutdown).
Hm, but they both apply to the graceful termination of workers/tasks in the event of a signal to shutdown. Is there any reason to be concerned about making the Uvicorn worker aware of the graceful shutdown timeout?
We are deprecating the workers module within Uvicorn. PR welcome on https://github.com/Kludex/uvicorn-worker.