forked from M-Labs/artiq
gui/applets: fix teardown of half-initialized applets
This commit is contained in:
parent
f6b5d6d20f
commit
5d293d14c6
@ -81,11 +81,12 @@ 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):
|
||||||
|
if hasattr(self, "server_task"):
|
||||||
self.server_task.cancel()
|
self.server_task.cancel()
|
||||||
await asyncio.wait([self.server_task])
|
await asyncio.wait([self.server_task])
|
||||||
|
|
||||||
@ -140,7 +141,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
|
||||||
|
|
||||||
@ -177,7 +178,8 @@ 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()
|
||||||
|
if hasattr(self.ipc, "process"):
|
||||||
self.ipc.write_pyon({"action": "terminate"})
|
self.ipc.write_pyon({"action": "terminate"})
|
||||||
try:
|
try:
|
||||||
await asyncio.wait_for(self.ipc.process.wait(), 2.0)
|
await asyncio.wait_for(self.ipc.process.wait(), 2.0)
|
||||||
|
Loading…
Reference in New Issue
Block a user