Skip to content

Commit

Permalink
Run self.wsgi.startup() before self._runner
Browse files Browse the repository at this point in the history
  • Loading branch information
f0t0n committed Aug 24, 2016
1 parent 43656d0 commit d90bbbe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
5 changes: 2 additions & 3 deletions aiohttp/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ def init_process(self):
super().init_process()

def run(self):
self.loop.run_until_complete(self.wsgi.startup())
self._runner = ensure_future(self._run(), loop=self.loop)

try:
self.loop.run_until_complete(asyncio.gather(self._runner,
self.wsgi.startup(),
loop=self.loop))
self.loop.run_until_complete(self._runner)
finally:
self.loop.close()

Expand Down
3 changes: 1 addition & 2 deletions tests/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ def test_run(worker, loop):
worker.loop = loop
worker._run = mock.Mock(
wraps=asyncio.coroutine(lambda: None))
worker.wsgi.startup = mock.Mock(
wraps=asyncio.coroutine(lambda: None))
worker.wsgi.startup = make_mocked_coro(None)
with pytest.raises(SystemExit):
worker.run()
assert worker._run.called
Expand Down

0 comments on commit d90bbbe

Please sign in to comment.