mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-26 11:48:27 +08:00
gui/applets: fix teardown of half-initialized applets
This commit is contained in:
parent
9e33bceb6f
commit
f2502026bf
@ -81,13 +81,14 @@ class AppletIPCServer(AsyncioParentComm):
|
|||||||
finally:
|
finally:
|
||||||
self.datasets_sub.notify_cbs.remove(self._on_mod)
|
self.datasets_sub.notify_cbs.remove(self._on_mod)
|
||||||
|
|
||||||
def start(self, embed_cb, fix_initial_size_cb):
|
def start_server(self, embed_cb, fix_initial_size_cb):
|
||||||
self.server_task = asyncio.ensure_future(
|
self.server_task = asyncio.ensure_future(
|
||||||
self.serve(embed_cb, fix_initial_size_cb))
|
self.serve(embed_cb, fix_initial_size_cb))
|
||||||
|
|
||||||
async def stop(self):
|
async def stop_server(self):
|
||||||
self.server_task.cancel()
|
if hasattr(self, "server_task"):
|
||||||
await asyncio.wait([self.server_task])
|
self.server_task.cancel()
|
||||||
|
await asyncio.wait([self.server_task])
|
||||||
|
|
||||||
|
|
||||||
class _AppletDock(QDockWidgetCloseDetect):
|
class _AppletDock(QDockWidgetCloseDetect):
|
||||||
@ -144,7 +145,7 @@ class _AppletDock(QDockWidgetCloseDetect):
|
|||||||
asyncio.ensure_future(
|
asyncio.ensure_future(
|
||||||
LogParser(self._get_log_source).stream_task(
|
LogParser(self._get_log_source).stream_task(
|
||||||
self.ipc.process.stderr))
|
self.ipc.process.stderr))
|
||||||
self.ipc.start(self.embed, self.fix_initial_size)
|
self.ipc.start_server(self.embed, self.fix_initial_size)
|
||||||
finally:
|
finally:
|
||||||
self.starting_stopping = False
|
self.starting_stopping = False
|
||||||
|
|
||||||
@ -166,18 +167,19 @@ class _AppletDock(QDockWidgetCloseDetect):
|
|||||||
self.starting_stopping = True
|
self.starting_stopping = True
|
||||||
|
|
||||||
if hasattr(self, "ipc"):
|
if hasattr(self, "ipc"):
|
||||||
await self.ipc.stop()
|
await self.ipc.stop_server()
|
||||||
self.ipc.write_pyon({"action": "terminate"})
|
if hasattr(self.ipc, "process"):
|
||||||
try:
|
self.ipc.write_pyon({"action": "terminate"})
|
||||||
await asyncio.wait_for(self.ipc.process.wait(), 2.0)
|
|
||||||
except:
|
|
||||||
logger.warning("Applet %s failed to exit, killing",
|
|
||||||
self.applet_name)
|
|
||||||
try:
|
try:
|
||||||
self.ipc.process.kill()
|
await asyncio.wait_for(self.ipc.process.wait(), 2.0)
|
||||||
except ProcessLookupError:
|
except:
|
||||||
pass
|
logger.warning("Applet %s failed to exit, killing",
|
||||||
await self.ipc.process.wait()
|
self.applet_name)
|
||||||
|
try:
|
||||||
|
self.ipc.process.kill()
|
||||||
|
except ProcessLookupError:
|
||||||
|
pass
|
||||||
|
await self.ipc.process.wait()
|
||||||
del self.ipc
|
del self.ipc
|
||||||
|
|
||||||
if hasattr(self, "embed_widget"):
|
if hasattr(self, "embed_widget"):
|
||||||
|
Loading…
Reference in New Issue
Block a user