signal handlers cant call async functions

This commit is contained in:
Victor Shyba 2019-01-23 17:03:45 -03:00 committed by Lex Berezhny
parent 2cb9d5c636
commit 3e4c9f25a8

View file

@ -117,8 +117,8 @@ class Server:
def run(self):
loop = asyncio.get_event_loop()
try:
loop.add_signal_handler(signal.SIGINT, self.stop)
loop.add_signal_handler(signal.SIGTERM, self.stop)
loop.add_signal_handler(signal.SIGINT, lambda: asyncio.ensure_future(self.stop()))
loop.add_signal_handler(signal.SIGTERM, lambda: asyncio.ensure_future(self.stop()))
loop.run_until_complete(self.start())
loop.run_until_complete(self.shutdown_event.wait())
finally: