From fd6c712dd432f6cbbadd53bb59e7c5ce7b07e0cb Mon Sep 17 00:00:00 2001 From: Randall Leeds Date: Mon, 15 Oct 2012 14:07:43 -0700 Subject: [PATCH] fix gevent graceful timeout for real `server.kill()` is too aggressive. It sends a GreenletExit exception to all the pool workers, causing them to exit immediately. A simple one line fix is to use `server.stop()`. In my testing, it appears that `server.stop_accepting()` will make the server stop listening, but pending connections already in the `accept()` backlog are still handled. With `server.stop()` the accept backlog is not handled, the listener is closed in the worker, but existing requests are allowed to exit gracefully. --- gunicorn/workers/ggevent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gunicorn/workers/ggevent.py b/gunicorn/workers/ggevent.py index b89cd4c2..90d5c262 100644 --- a/gunicorn/workers/ggevent.py +++ b/gunicorn/workers/ggevent.py @@ -79,7 +79,7 @@ class GeventWorker(AsyncWorker): try: # Stop accepting requests - server.kill() + server.close() # Handle current requests until graceful_timeout ts = time.time()