Skip to content

Commit

Permalink
Fix timeouts for async workers.
Browse files Browse the repository at this point in the history
  • Loading branch information
davisp committed Jul 9, 2010
1 parent 3b8a74f commit a9c916f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
8 changes: 6 additions & 2 deletions gunicorn/workers/async.py
Expand Up @@ -21,15 +21,19 @@ def __init__(self, *args, **kwargs):
self.worker_connections = self.cfg.worker_connections

def timeout_ctx(self):
return self.parser.next()
raise NotImplemented()

def handle(self, client, addr):
try:
try:
parser = http.RequestParser(client)
try:
while True:
req = self.timeout_ctx()
timeout = self.timeout_ctx()
try:
req = parser.next()
finally:
timeout.cancel()
if not req:
break
self.handle_request(req, client, addr)
Expand Down
9 changes: 1 addition & 8 deletions gunicorn/workers/geventlet.py
Expand Up @@ -30,14 +30,7 @@ def init_process(self):
super(EventletWorker, self).init_process()

def timeout_ctx(self):
timeout = eventlet.Timeout(self.cfg.keepalive)
try:
try:
return super(timeout_ctx, self)()
except eventlet.Timeout, t:
pass
finally:
timeout.cancel()
return eventlet.Timeout(self.cfg.keepalive)

def run(self):
self.socket.setblocking(1)
Expand Down
6 changes: 2 additions & 4 deletions gunicorn/workers/ggevent.py
Expand Up @@ -23,10 +23,8 @@ def setup(cls):

def timeout_ctx(self):
timeout = gevent.Timeout(self.cfg.keepalive)
try:
return super(GEventWorker, self).timeout_ctx()
except gevent.Timeout:
return None
timeout.start()
return timeout

def run(self):
self.socket.setblocking(1)
Expand Down

0 comments on commit a9c916f

Please sign in to comment.