Skip to content

Commit

Permalink
ease integration with grainbows, put accept connection in its own
Browse files Browse the repository at this point in the history
method.
  • Loading branch information
benoitc committed Mar 11, 2010
1 parent f2adef3 commit 275031f
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions gunicorn/worker.py
Expand Up @@ -95,6 +95,15 @@ def init_process(self):
self.init_signals()


def accept(self):
try:
client, addr = self.socket.accept()
self.handle(client, addr)
self.nr += 1
except socket.error, e:
if e[0] not in (errno.EAGAIN, errno.ECONNABORTED):
raise

def run(self):
self.init_process()
self.nr = 0
Expand All @@ -106,13 +115,9 @@ def run(self):
while self.alive:
self.nr = 0
self.notify()
try:
client, addr = self.socket.accept()
self.handle(client, addr)
self.nr += 1
except socket.error, e:
if e[0] not in (errno.EAGAIN, errno.ECONNABORTED):
raise

# accept a new connection
self.accept()

# Keep processing clients until no one is waiting.
# This prevents the need to select() for every
Expand Down

0 comments on commit 275031f

Please sign in to comment.