Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UvicornWorker: respect the gunicorn graceful shutdown timeout #2094

Closed
wants to merge 1 commit into from

Conversation

BrendanGraham14
Copy link

@BrendanGraham14 BrendanGraham14 commented Sep 6, 2023

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

  • 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 UvicornWorker doesn't have any tests currently.
  • I've updated the documentation accordingly.

@Kludex
Copy link
Member

Kludex commented Sep 6, 2023

I don't think they are equivalent.

@BrendanGraham14
Copy link
Author

@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_timeout
After 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.

@Kludex
Copy link
Member

Kludex commented Sep 6, 2023

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).

@BrendanGraham14
Copy link
Author

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?

@Kludex
Copy link
Member

Kludex commented Apr 13, 2024

We are deprecating the workers module within Uvicorn. PR welcome on https://github.com/Kludex/uvicorn-worker.

@Kludex Kludex closed this Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants