1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-23 23:38:21 +00:00

Fix asyncio error when closing the app

Fix #310, https://github.com/GNS3/gns3-gui/issues/705
This commit is contained in:
Julien Duponchelle 2015-10-12 16:16:44 +02:00
parent a6286db7b1
commit 0a536278fc
3 changed files with 4 additions and 6 deletions

View File

@ -61,7 +61,6 @@ class BaseVM:
def __del__(self):
self.close()
if self._temporary_directory is not None:
if os.path.exists(self._temporary_directory):
shutil.rmtree(self._temporary_directory, ignore_errors=True)

View File

@ -588,7 +588,7 @@ class QemuVM(BaseVM):
log.error("Could not start QEMU {}: {}\n{}".format(self.qemu_path, e, stdout))
raise QemuError("Could not start QEMU {}: {}\n{}".format(self.qemu_path, e, stdout))
self._set_process_priority()
yield from self._set_process_priority()
if self._cpu_throttling:
self._set_cpu_throttling()
@ -603,7 +603,7 @@ class QemuVM(BaseVM):
log.info('Stopping QEMU VM "{}" PID={}'.format(self._name, self._process.pid))
try:
self._process.terminate()
self._process.wait()
yield from self._process.wait()
except subprocess.TimeoutExpired:
try:
self._process.kill()

View File

@ -103,10 +103,9 @@ class Server:
def _signal_handling(self):
@asyncio.coroutine
def signal_handler(signame):
log.warning("Server has got signal {}, exiting...".format(signame))
yield from self.shutdown_server()
asyncio.async(self.shutdown_server())
signals = ["SIGTERM", "SIGINT"]
if sys.platform.startswith("win"):
@ -115,7 +114,7 @@ class Server:
signals.extend(["SIGHUP", "SIGQUIT"])
for signal_name in signals:
callback = functools.partial(asyncio.async, signal_handler(signal_name))
callback = functools.partial(signal_handler, signal_name)
if sys.platform.startswith("win"):
# add_signal_handler() is not yet supported on Windows
signal.signal(getattr(signal, signal_name), callback)