mirror of
https://github.com/GNS3/gns3-server
synced 2025-06-03 14:49:02 +00:00
Fix asyncio error when closing the app
Fix #310, https://github.com/GNS3/gns3-gui/issues/705
This commit is contained in:
parent
a6286db7b1
commit
0a536278fc
@ -61,7 +61,6 @@ class BaseVM:
|
|||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
|
|
||||||
self.close()
|
|
||||||
if self._temporary_directory is not None:
|
if self._temporary_directory is not None:
|
||||||
if os.path.exists(self._temporary_directory):
|
if os.path.exists(self._temporary_directory):
|
||||||
shutil.rmtree(self._temporary_directory, ignore_errors=True)
|
shutil.rmtree(self._temporary_directory, ignore_errors=True)
|
||||||
|
@ -588,7 +588,7 @@ class QemuVM(BaseVM):
|
|||||||
log.error("Could not start QEMU {}: {}\n{}".format(self.qemu_path, e, stdout))
|
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))
|
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:
|
if self._cpu_throttling:
|
||||||
self._set_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))
|
log.info('Stopping QEMU VM "{}" PID={}'.format(self._name, self._process.pid))
|
||||||
try:
|
try:
|
||||||
self._process.terminate()
|
self._process.terminate()
|
||||||
self._process.wait()
|
yield from self._process.wait()
|
||||||
except subprocess.TimeoutExpired:
|
except subprocess.TimeoutExpired:
|
||||||
try:
|
try:
|
||||||
self._process.kill()
|
self._process.kill()
|
||||||
|
@ -103,10 +103,9 @@ class Server:
|
|||||||
|
|
||||||
def _signal_handling(self):
|
def _signal_handling(self):
|
||||||
|
|
||||||
@asyncio.coroutine
|
|
||||||
def signal_handler(signame):
|
def signal_handler(signame):
|
||||||
log.warning("Server has got signal {}, exiting...".format(signame))
|
log.warning("Server has got signal {}, exiting...".format(signame))
|
||||||
yield from self.shutdown_server()
|
asyncio.async(self.shutdown_server())
|
||||||
|
|
||||||
signals = ["SIGTERM", "SIGINT"]
|
signals = ["SIGTERM", "SIGINT"]
|
||||||
if sys.platform.startswith("win"):
|
if sys.platform.startswith("win"):
|
||||||
@ -115,7 +114,7 @@ class Server:
|
|||||||
signals.extend(["SIGHUP", "SIGQUIT"])
|
signals.extend(["SIGHUP", "SIGQUIT"])
|
||||||
|
|
||||||
for signal_name in signals:
|
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"):
|
if sys.platform.startswith("win"):
|
||||||
# add_signal_handler() is not yet supported on Windows
|
# add_signal_handler() is not yet supported on Windows
|
||||||
signal.signal(getattr(signal, signal_name), callback)
|
signal.signal(getattr(signal, signal_name), callback)
|
||||||
|
Loading…
Reference in New Issue
Block a user