Skip to content

Commit

Permalink
[eventlet] handle QUIT in a new coroutine
Browse files Browse the repository at this point in the history
Just like in the gevent worker, a blocking call should only be executed
from within a coroutine. The AssertionError around the main loop of the
eventlet worker can be removed, since it was there to catch
the exception raised by the sleep.
  • Loading branch information
tilgovi committed Mar 13, 2016
1 parent bbe302e commit 3be8476
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions gunicorn/workers/geventlet.py
Expand Up @@ -94,6 +94,9 @@ def init_process(self):
self.patch()
super(EventletWorker, self).init_process()

def handle_quit(self, sig, frame):
eventlet.spawn(super(EventletWorker, self).handle_quit, sig, frame)

def timeout_ctx(self):
return eventlet.Timeout(self.cfg.keepalive or None, False)

Expand All @@ -118,11 +121,7 @@ def run(self):

while self.alive:
self.notify()
try:
eventlet.sleep(1.0)
except AssertionError:
self.alive = False
break
eventlet.sleep(1.0)

self.notify()
try:
Expand Down

0 comments on commit 3be8476

Please sign in to comment.