forked from M-Labs/artiq
gui/applets: prevent concurrent process start/stop
This commit is contained in:
parent
92c0ede689
commit
29d4755567
|
@ -95,11 +95,17 @@ class AppletDock(dockarea.Dock):
|
||||||
self.applet_name = name
|
self.applet_name = name
|
||||||
self.command = command
|
self.command = command
|
||||||
|
|
||||||
|
self.starting_stopping = False
|
||||||
|
|
||||||
def rename(self, name):
|
def rename(self, name):
|
||||||
self.applet_name = name
|
self.applet_name = name
|
||||||
self.label.setText("Applet: " + name)
|
self.label.setText("Applet: " + name)
|
||||||
|
|
||||||
async def start(self):
|
async def start(self):
|
||||||
|
if self.starting_stopping:
|
||||||
|
return
|
||||||
|
self.starting_stopping = True
|
||||||
|
|
||||||
self.ipc = AppletIPCServer(self.datasets_sub)
|
self.ipc = AppletIPCServer(self.datasets_sub)
|
||||||
if "{ipc_address}" not in self.command:
|
if "{ipc_address}" not in self.command:
|
||||||
logger.warning("IPC address missing from command for %s",
|
logger.warning("IPC address missing from command for %s",
|
||||||
|
@ -114,6 +120,8 @@ class AppletDock(dockarea.Dock):
|
||||||
exc_info=True)
|
exc_info=True)
|
||||||
self.ipc.start(self.embed, self.fix_initial_size)
|
self.ipc.start(self.embed, self.fix_initial_size)
|
||||||
|
|
||||||
|
self.starting_stopping = False
|
||||||
|
|
||||||
def embed(self, win_id):
|
def embed(self, win_id):
|
||||||
logger.debug("capturing window 0x%x for %s", win_id, self.applet_name)
|
logger.debug("capturing window 0x%x for %s", win_id, self.applet_name)
|
||||||
self.embed_window = QtGui.QWindow.fromWinId(win_id)
|
self.embed_window = QtGui.QWindow.fromWinId(win_id)
|
||||||
|
@ -127,6 +135,10 @@ class AppletDock(dockarea.Dock):
|
||||||
self.embed_window.resize(self.embed_widget.size())
|
self.embed_window.resize(self.embed_widget.size())
|
||||||
|
|
||||||
async def terminate(self):
|
async def terminate(self):
|
||||||
|
if self.starting_stopping:
|
||||||
|
return
|
||||||
|
self.starting_stopping = True
|
||||||
|
|
||||||
if hasattr(self, "ipc"):
|
if hasattr(self, "ipc"):
|
||||||
await self.ipc.stop()
|
await self.ipc.stop()
|
||||||
self.ipc.write_pyon({"action": "terminate"})
|
self.ipc.write_pyon({"action": "terminate"})
|
||||||
|
@ -142,9 +154,12 @@ class AppletDock(dockarea.Dock):
|
||||||
await self.ipc.process.wait()
|
await self.ipc.process.wait()
|
||||||
del self.ipc
|
del self.ipc
|
||||||
|
|
||||||
|
if hasattr(self, "embed_widget"):
|
||||||
self.embed_widget.deleteLater()
|
self.embed_widget.deleteLater()
|
||||||
del self.embed_widget
|
del self.embed_widget
|
||||||
|
|
||||||
|
self.starting_stopping = False
|
||||||
|
|
||||||
async def restart(self):
|
async def restart(self):
|
||||||
await self.terminate()
|
await self.terminate()
|
||||||
await self.start()
|
await self.start()
|
||||||
|
|
Loading…
Reference in New Issue