From 68b48b969403a8521056b40bd50e85b742ac5cee Mon Sep 17 00:00:00 2001 From: Randall Leeds Date: Tue, 6 Aug 2013 02:46:21 -0700 Subject: [PATCH] Forward-compatibility for gevent graceful shutdown This commit closes the loop on fd6c712. Aforementioned commit fixed observable problems in my testing with gevent 1.0 release candidates but the explanation given at the time was curiously bogus. It came from a misreading of pools and servers as used in the ggevent worker. With this change, both versions of gevent should support graceful and non-graceful shutdown. --- gunicorn/workers/ggevent.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gunicorn/workers/ggevent.py b/gunicorn/workers/ggevent.py index f792b917..dcdfad6f 100644 --- a/gunicorn/workers/ggevent.py +++ b/gunicorn/workers/ggevent.py @@ -97,7 +97,11 @@ class GeventWorker(AsyncWorker): try: # Stop accepting requests - [server.stop_accepting() for server in servers] + for server in servers: + if hasattr(server, 'close'): # gevent 1.0 + server.close() + if hasattr(server, 'kill'): # gevent < 1.0 + server.kill() # Handle current requests until graceful_timeout ts = time.time()