Skip to content

Commit

Permalink
fix worker
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Oct 10, 2013
1 parent 8061d03 commit 2fb6a3b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 8 additions & 3 deletions asynchttp/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ def factory(self):

@tulip.coroutine
def _run(self):
servers = [
self.loop.create_server(self.factory, sock=sock.sock)
for sock in self.sockets]
servers = []
def add_server(t):
servers.append(t.result())

for sock in self.sockets:
t = tulip.async(
self.loop.create_server(self.factory, sock=sock.sock))
t.add_done_callback(add_server)

# If our parent changed then we shut down.
pid = os.getpid()
Expand Down
3 changes: 2 additions & 1 deletion tests/worker_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def test_factory(self):

self.assertIsInstance(f, WSGIServerHttpProtocol)

def test__run(self):
@unittest.mock.patch('asynchttp.worker.tulip')
def test__run(self, m_tulip):
self.worker.ppid = 1
self.worker.alive = True
self.worker.sockets = [unittest.mock.Mock()]
Expand Down

0 comments on commit 2fb6a3b

Please sign in to comment.