Skip to content

Commit

Permalink
fix async keep-alive timeout noise
Browse files Browse the repository at this point in the history
  • Loading branch information
tilgovi committed Sep 20, 2011
1 parent 05f0222 commit 0efcade
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions gunicorn/workers/async.py
Expand Up @@ -6,6 +6,7 @@
from datetime import datetime
import errno
import socket
import sys

import gunicorn.http as http
import gunicorn.http.wsgi as wsgi
Expand All @@ -21,7 +22,7 @@ def __init__(self, *args, **kwargs):
self.worker_connections = self.cfg.worker_connections

def timeout_ctx(self):
raise NotImplemented()
raise NotImplementedError()

def handle(self, client, addr):
try:
Expand All @@ -32,7 +33,11 @@ def handle(self, client, addr):
timeout = self.timeout_ctx()
req = None
try:
req = parser.next()
try:
req = parser.next()
except:
if sys.exc_info()[1] is not timeout:
raise
finally:
timeout.cancel()
if not req:
Expand Down
2 changes: 1 addition & 1 deletion gunicorn/workers/geventlet.py
Expand Up @@ -30,7 +30,7 @@ def init_process(self):
super(EventletWorker, self).init_process()

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

def run(self):
self.socket = GreenSocket(family_or_realsock=self.socket.sock)
Expand Down
4 changes: 2 additions & 2 deletions gunicorn/workers/ggevent.py
Expand Up @@ -49,10 +49,10 @@ def setup(cls):


def timeout_ctx(self):
timeout = gevent.Timeout(self.cfg.keepalive)
timeout = gevent.Timeout(self.cfg.keepalive, False)
timeout.start()
return timeout

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

Expand Down

0 comments on commit 0efcade

Please sign in to comment.