From 3e4c9f25a863799ea5648942734ca9b628119082 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Wed, 23 Jan 2019 17:03:45 -0300 Subject: [PATCH] signal handlers cant call async functions --- torba/server/server.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/torba/server/server.py b/torba/server/server.py index 433df49fa..a9e980951 100644 --- a/torba/server/server.py +++ b/torba/server/server.py @@ -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: