Commit 5e9fd22d authored by Andrey Veltischev's avatar Andrey Veltischev
Browse files

Remove endless sleep from aiohttp, run until complete cancelled tasks

parent f7e26736
......@@ -38,8 +38,6 @@ class AioAppWrapper:
await self.runner.setup()
site = web.TCPSite(self.runner, '0.0.0.0', self.port)
await site.start()
while True:
await asyncio.sleep(3600)
def shutdown(self):
LOG.info('Shutdown aiohttp app')
......@@ -95,11 +93,14 @@ class ApplicationWrapper:
def run_all(self):
self.handle_signal(signal.SIGTERM, _raise_graceful_exit)
self.handle_signal(signal.SIGHUP, _raise_graceful_exit)
tasks = asyncio.gather(*[app.initialize() for app in self.apps])
try:
LOG.info('Start serving')
self.loop.run_until_complete(asyncio.gather(*[app.initialize() for app in self.apps]))
self.loop.run_until_complete(tasks)
except KeyboardInterrupt:
pass
finally:
for app in self.apps:
app.shutdown()
self.loop.run_until_complete(tasks)
print('Stopping main wrapper')
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment