mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
fix run loop in sync worker
This commit is contained in:
parent
d1a0973225
commit
fd95f66f2d
@ -18,6 +18,8 @@ import gunicorn.util as util
|
|||||||
import gunicorn.workers.base as base
|
import gunicorn.workers.base as base
|
||||||
from gunicorn import six
|
from gunicorn import six
|
||||||
|
|
||||||
|
class StopWaiting(Exception):
|
||||||
|
""" exception raised to stop waiting for a connnection """
|
||||||
|
|
||||||
class SyncWorker(base.Worker):
|
class SyncWorker(base.Worker):
|
||||||
|
|
||||||
@ -41,7 +43,7 @@ class SyncWorker(base.Worker):
|
|||||||
if self.nr < 0:
|
if self.nr < 0:
|
||||||
return self.sockets
|
return self.sockets
|
||||||
else:
|
else:
|
||||||
return False
|
raise StopWaiting
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def is_parent_alive(self):
|
def is_parent_alive(self):
|
||||||
@ -75,15 +77,18 @@ class SyncWorker(base.Worker):
|
|||||||
if not self.is_parent_alive():
|
if not self.is_parent_alive():
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self.wait(timeout):
|
try:
|
||||||
|
self.wait(timeout)
|
||||||
|
except StopWaiting:
|
||||||
return
|
return
|
||||||
|
|
||||||
def run_for_multiple(self, timeout):
|
def run_for_multiple(self, timeout):
|
||||||
while self.alive:
|
while self.alive:
|
||||||
self.notify()
|
self.notify()
|
||||||
|
|
||||||
ready = self.wait(timeout)
|
try:
|
||||||
if not ready:
|
ready = self.wait(timeout)
|
||||||
|
except StopWaiting:
|
||||||
return
|
return
|
||||||
|
|
||||||
for listener in ready:
|
for listener in ready:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user