From d90bbbec63872754666996d0d5a59ea54c62f774 Mon Sep 17 00:00:00 2001 From: Eugene Neydenov Date: Wed, 24 Aug 2016 11:46:25 +0300 Subject: [PATCH] Run self.wsgi.startup() before self._runner --- aiohttp/worker.py | 5 ++--- tests/test_worker.py | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/aiohttp/worker.py b/aiohttp/worker.py index 92c3b276ff0..ce48fae6386 100644 --- a/aiohttp/worker.py +++ b/aiohttp/worker.py @@ -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() diff --git a/tests/test_worker.py b/tests/test_worker.py index dc6e9f2abe0..9bc286d476d 100644 --- a/tests/test_worker.py +++ b/tests/test_worker.py @@ -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