1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-24 17:28:08 +00:00

Force closing the event loop to avoid warning with Python 3.4.3

Fix #177
This commit is contained in:
Julien Duponchelle 2015-05-05 11:33:47 +02:00
parent 18c4154376
commit b7dac1bec4

View File

@ -27,6 +27,7 @@ import aiohttp
import functools
import types
import time
import atexit
from .web.route import Route
from .web.request_handler import RequestHandler
@ -173,6 +174,18 @@ class Server:
return
yield from embed(globals(), locals(), return_asyncio_coroutine=True, patch_stdout=True)
def _exit_handling(self):
def close_asyncio_loop():
loop = None
try:
loop = asyncio.get_event_loop()
except AttributeError:
pass
if loop is not None:
loop.close()
atexit.register(close_asyncio_loop)
def run(self):
"""
Starts the server.
@ -216,6 +229,8 @@ class Server:
self._loop.run_until_complete(self._run_application(self._handler, ssl_context))
self._signal_handling()
self._exit_handling()
if server_config.getboolean("live"):
log.info("Code live reload is enabled, watching for file changes")
self._loop.call_later(1, self._reload_hook)