From 8270d43cc34b32c4e1e4e286e551c31c54ae228e Mon Sep 17 00:00:00 2001 From: Xie Shi Date: Mon, 15 Jul 2013 19:03:53 +0800 Subject: [PATCH] small tweak of 53c4484 since timeout patch affect only select call, it is better to not change self.timeout. --- gunicorn/workers/sync.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gunicorn/workers/sync.py b/gunicorn/workers/sync.py index b57f28b9..06de9f6e 100644 --- a/gunicorn/workers/sync.py +++ b/gunicorn/workers/sync.py @@ -26,11 +26,6 @@ class SyncWorker(base.Worker): for s in self.sockets: s.setblocking(0) - if not self.timeout: - # if no timeout is given the worker will never wait and will - # use the CPU for nothing. This minimal timeout prevent it. - self.timeout = 0.5 - ready = self.sockets while self.alive: self.notify() @@ -64,7 +59,12 @@ class SyncWorker(base.Worker): try: self.notify() - ret = select.select(self.sockets, [], self.PIPE, self.timeout) + + # if no timeout is given the worker will never wait and will + # use the CPU for nothing. This minimal timeout prevent it. + timeout = self.timeout or 0.5 + + ret = select.select(self.sockets, [], self.PIPE, timeout) if ret[0]: ready = ret[0] continue