From fd95f66f2dc3dc8de18f4e5d8ca9234bde48e672 Mon Sep 17 00:00:00 2001 From: benoitc Date: Fri, 19 Dec 2014 08:59:22 +0100 Subject: [PATCH] fix run loop in sync worker --- gunicorn/workers/sync.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gunicorn/workers/sync.py b/gunicorn/workers/sync.py index 42f0c68e..def77970 100644 --- a/gunicorn/workers/sync.py +++ b/gunicorn/workers/sync.py @@ -18,6 +18,8 @@ import gunicorn.util as util import gunicorn.workers.base as base from gunicorn import six +class StopWaiting(Exception): + """ exception raised to stop waiting for a connnection """ class SyncWorker(base.Worker): @@ -41,7 +43,7 @@ class SyncWorker(base.Worker): if self.nr < 0: return self.sockets else: - return False + raise StopWaiting raise def is_parent_alive(self): @@ -75,15 +77,18 @@ class SyncWorker(base.Worker): if not self.is_parent_alive(): return - if not self.wait(timeout): + try: + self.wait(timeout) + except StopWaiting: return def run_for_multiple(self, timeout): while self.alive: self.notify() - ready = self.wait(timeout) - if not ready: + try: + ready = self.wait(timeout) + except StopWaiting: return for listener in ready: