@@ -95,11 +95,17 @@ def __init__(self, datasets_sub, uid, name, command):
95
95
self .applet_name = name
96
96
self .command = command
97
97
98
+ self .starting_stopping = False
99
+
98
100
def rename (self , name ):
99
101
self .applet_name = name
100
102
self .label .setText ("Applet: " + name )
101
103
102
104
async def start (self ):
105
+ if self .starting_stopping :
106
+ return
107
+ self .starting_stopping = True
108
+
103
109
self .ipc = AppletIPCServer (self .datasets_sub )
104
110
if "{ipc_address}" not in self .command :
105
111
logger .warning ("IPC address missing from command for %s" ,
@@ -114,6 +120,8 @@ async def start(self):
114
120
exc_info = True )
115
121
self .ipc .start (self .embed , self .fix_initial_size )
116
122
123
+ self .starting_stopping = False
124
+
117
125
def embed (self , win_id ):
118
126
logger .debug ("capturing window 0x%x for %s" , win_id , self .applet_name )
119
127
self .embed_window = QtGui .QWindow .fromWinId (win_id )
@@ -127,6 +135,10 @@ def fix_initial_size(self):
127
135
self .embed_window .resize (self .embed_widget .size ())
128
136
129
137
async def terminate (self ):
138
+ if self .starting_stopping :
139
+ return
140
+ self .starting_stopping = True
141
+
130
142
if hasattr (self , "ipc" ):
131
143
await self .ipc .stop ()
132
144
self .ipc .write_pyon ({"action" : "terminate" })
@@ -142,9 +154,12 @@ async def terminate(self):
142
154
await self .ipc .process .wait ()
143
155
del self .ipc
144
156
157
+ if hasattr (self , "embed_widget" ):
145
158
self .embed_widget .deleteLater ()
146
159
del self .embed_widget
147
160
161
+ self .starting_stopping = False
162
+
148
163
async def restart (self ):
149
164
await self .terminate ()
150
165
await self .start ()
0 commit comments