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

Fixes RuntimeError: Event loop is closed. Fixes #266.

This commit is contained in:
Jeremy 2015-07-20 16:02:28 -06:00
parent dfd6af3c22
commit 6ee94331d4
2 changed files with 14 additions and 4 deletions

View File

@ -210,7 +210,7 @@ class VMwareVM(BaseVM):
if self._adapter_type != "default": if self._adapter_type != "default":
adapter_type = "ethernet{}.virtualdev".format(adapter_number) adapter_type = "ethernet{}.virtualdev".format(adapter_number)
if adapter_type in self._vmx_pairs and self._vmx_pairs[adapter_type] != self._adapter_type: if adapter_type in self._vmx_pairs and self._vmx_pairs[adapter_type] != self._adapter_type:
raise VMwareError("Network adapter {} is not of type {}, please fix or remove it".format(self._adapter_type)) raise VMwareError("Network adapter {} is not of type {}, please fix or remove it".format(adapter_number, self._adapter_type))
# check if connected to an adapter configured for nat or bridge # check if connected to an adapter configured for nat or bridge
if self._ethernet_adapters[adapter_number].get_nio(0) and not self._use_any_adapter: if self._ethernet_adapters[adapter_number].get_nio(0) and not self._use_any_adapter:

View File

@ -85,7 +85,8 @@ class Server:
""" """
if self._handler: if self._handler:
yield from self._handler.finish_connections() yield from self._handler.finish_connections(1.0)
self._handler = None
for module in MODULES: for module in MODULES:
log.debug("Unloading module {}".format(module.__name__)) log.debug("Unloading module {}".format(module.__name__))
@ -176,6 +177,10 @@ class Server:
yield from embed(globals(), locals(), return_asyncio_coroutine=True, patch_stdout=True) yield from embed(globals(), locals(), return_asyncio_coroutine=True, patch_stdout=True)
def _exit_handling(self): def _exit_handling(self):
"""
Makes sure the asyncio loop is closed.
"""
def close_asyncio_loop(): def close_asyncio_loop():
loop = None loop = None
try: try:
@ -227,9 +232,9 @@ class Server:
log.info("Starting server on {}:{}".format(self._host, self._port)) log.info("Starting server on {}:{}".format(self._host, self._port))
self._handler = app.make_handler(handler=RequestHandler) self._handler = app.make_handler(handler=RequestHandler)
self._loop.run_until_complete(self._run_application(self._handler, ssl_context)) server = self._run_application(self._handler, ssl_context)
self._loop.run_until_complete(server)
self._signal_handling() self._signal_handling()
self._exit_handling() self._exit_handling()
if server_config.getboolean("live"): if server_config.getboolean("live"):
@ -246,3 +251,8 @@ class Server:
# on Windows when the process gets the SIGBREAK signal # on Windows when the process gets the SIGBREAK signal
# TypeError: async() takes 1 positional argument but 3 were given # TypeError: async() takes 1 positional argument but 3 were given
log.warning("TypeError exception in the loop {}".format(e)) log.warning("TypeError exception in the loop {}".format(e))
finally:
if self._handler:
self._loop.run_until_complete(self._handler.finish_connections(1.0))
server.close()
self._loop.run_until_complete(app.finish())