diff --git a/gns3server/modules/vmware/vmware_vm.py b/gns3server/modules/vmware/vmware_vm.py index 01771718..79cc2bf7 100644 --- a/gns3server/modules/vmware/vmware_vm.py +++ b/gns3server/modules/vmware/vmware_vm.py @@ -210,7 +210,7 @@ class VMwareVM(BaseVM): if self._adapter_type != "default": adapter_type = "ethernet{}.virtualdev".format(adapter_number) 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 if self._ethernet_adapters[adapter_number].get_nio(0) and not self._use_any_adapter: diff --git a/gns3server/server.py b/gns3server/server.py index ad75a550..28dcca62 100644 --- a/gns3server/server.py +++ b/gns3server/server.py @@ -85,7 +85,8 @@ class Server: """ if self._handler: - yield from self._handler.finish_connections() + yield from self._handler.finish_connections(1.0) + self._handler = None for module in MODULES: 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) def _exit_handling(self): + """ + Makes sure the asyncio loop is closed. + """ + def close_asyncio_loop(): loop = None try: @@ -227,9 +232,9 @@ class Server: log.info("Starting server on {}:{}".format(self._host, self._port)) 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._exit_handling() if server_config.getboolean("live"): @@ -246,3 +251,8 @@ class Server: # on Windows when the process gets the SIGBREAK signal # TypeError: async() takes 1 positional argument but 3 were given 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())