-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Gunicorn 20.1.0 worker does not respect graceful timeout option #2839
Comments
I was facing a similar problem (frappe/bench#1493) but it turned out to be related to supervisord. I can't reproduce this with vanilla gunicorn. Is this still valid? Here's what I did to reproduce:
def slow_function():
import time
for i in range(300):
print("Sleeping", i)
time.sleep(1) This is what get as output. Since we aren't issuing request at the same exact time, the time is off by a second. but that's acceptable (?) I curled a request in one terminal and sent SIGTERM
|
UseCase: save work on timeout, idempotent handlers I found this problem too. It behaves differently depending on worker. gthread ignores the timeout and gives infinite time (from the users perspective at least, but maybe both treads must be stuck to trigger).
|
well graceful timeout purpose is to wait soem long worker tp o be killed but doesn'tnot ensure it will wait this tile so send the signal. I will re-check for the coming version. |
I'd like to keep all graceful shutdown related issues to #1236, so I'm going to close this one. It's documented in that issue that the threaded worker might not behave exactly like the others with respect to graceful shutdown. |
@tilgovi Ack! My issue is not related to graceful shutdown, but to timeout behavior. All this is about a misunderstanding of the documentation that the options --timeout and --graceful-timeout are related. My misunderstanding was: The actual meaning of the option is "set a different timeout for graceful shutdown". Suggest to improve the doc to avoid this misinterpretation or call the option --graceful-shutdown-timeout |
Thanks for following up. I'll close this for now, but I've been contemplating for a long time what might be done to make timeout behavior clearer and I'll take your idea under consideration. |
gunicorn 20.1.0
Example code: (download django-mvp.zip)
i.e. it sleeps for 10 secs and print.
Test 1 Timeout < 10 graceful timeout > 10
Expected: Worker terminate gracefully.
How to run test:
GET test url:
curl -X 'GET' 'http://localhost:8000/polls/test/'
while running send TERM signal:
kill -s TERM {pid}
Result: Worker does not terminate gracefully.
Test 2 timeout > 10 graceful timeout < 10
Expected: worker to be killed without completing request.
i.e. gunicorn worker only seems to respect timeout option but not graceful timeout option.
This is not consistent with the documented behaviour.
I notice however, that gunicorn log does not show
[INFO] Handling signal: TERM
in console?It does for INT signal for some reason.
The text was updated successfully, but these errors were encountered: