From 1d6d2a39f0bdc33701525281c224814ca50a4480 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Fri, 27 Feb 2015 12:51:39 -0700 Subject: [PATCH] Allow signals to be processed on Windows. --- gns3server/main.py | 1 - gns3server/server.py | 10 +++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/gns3server/main.py b/gns3server/main.py index 056d2b62..d6fb969d 100644 --- a/gns3server/main.py +++ b/gns3server/main.py @@ -21,7 +21,6 @@ import datetime import sys import locale import argparse -import configparser from gns3server.server import Server from gns3server.web.logger import init_logger diff --git a/gns3server/server.py b/gns3server/server.py index 406c0b3f..af97ccfc 100644 --- a/gns3server/server.py +++ b/gns3server/server.py @@ -167,7 +167,15 @@ class Server: server_config = Config.instance().get_section_config("Server") if sys.platform.startswith("win"): # use the Proactor event loop on Windows - asyncio.set_event_loop(asyncio.ProactorEventLoop()) + loop = asyncio.ProactorEventLoop() + + # Add a periodic callback to give a chance to process signals on Windows + # because asyncio.add_signal_handler() is not supported yet on that platform + # otherwise the loop runs outside of signal module's ability to trap signals. + def wakeup(): + loop.call_later(0.1, wakeup) + loop.call_later(0.1, wakeup) + asyncio.set_event_loop(loop) ssl_context = None if server_config.getboolean("ssl"):