From 29127895b99a0b6b5ead9aefd2747c9d6d8ca6f8 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Mon, 30 May 2016 15:18:49 +0200 Subject: [PATCH] Fix the watch local server configuration file Ref #539 --- gns3server/main.py | 7 +++++++ gns3server/web/web_server.py | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/gns3server/main.py b/gns3server/main.py index e1f3aa44..5a8f70cf 100644 --- a/gns3server/main.py +++ b/gns3server/main.py @@ -31,6 +31,13 @@ import gns3server.utils.get_resource import os import sys +# To avoid strange bug later we switch the event loop before any other operation +if sys.platform.startswith("win"): + import asyncio + # use the Proactor event loop on Windows + loop = asyncio.ProactorEventLoop() + + def daemonize(): """ diff --git a/gns3server/web/web_server.py b/gns3server/web/web_server.py index 366c44e0..11c1f424 100644 --- a/gns3server/web/web_server.py +++ b/gns3server/web/web_server.py @@ -177,11 +177,8 @@ class WebServer: logger = logging.getLogger("asyncio") logger.setLevel(logging.ERROR) - server_config = Config.instance().get_section_config("Server") if sys.platform.startswith("win"): - # use the Proactor event loop on Windows - loop = asyncio.ProactorEventLoop() - + loop = asyncio.get_event_loop() # 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. @@ -190,6 +187,9 @@ class WebServer: loop.call_later(0.5, wakeup) asyncio.set_event_loop(loop) + server_config = Config.instance().get_section_config("Server") + + ssl_context = None if server_config.getboolean("ssl"): if sys.platform.startswith("win"):