@@ -255,12 +255,17 @@ def set_default_parameters(cls, params):
255
255
raise ActionCreationError (msg )
256
256
setattr (cls , name , value )
257
257
258
+ @property
259
+ def interrupted (self ):
260
+ return self ._stop_thread and self ._stop_thread .is_set ()
261
+
258
262
def __init__ (self , name , module , iteration , tick , parameters ):
259
263
"""
260
264
Initialize action
261
265
"""
262
266
# Set properties
263
267
self ._log_dict = None
268
+ self ._stop_thread = None
264
269
self ._name = name
265
270
self ._module = module
266
271
self ._iteration = iteration
@@ -294,7 +299,7 @@ def execute(self, stop_thread, log_dict):
294
299
if not self ._valid_pre_run_flag :
295
300
self .warning ('PreRun returned False' )
296
301
# Stop thread activated case
297
- elif self ._stop_thread . is_set () :
302
+ elif self .interrupted :
298
303
self .warning ('The stop mecanism has been activated during PreRun' )
299
304
# If PreRun returned True
300
305
elif self ._valid_pre_run_flag :
@@ -318,7 +323,7 @@ def execute(self, stop_thread, log_dict):
318
323
self .warning (msg )
319
324
break
320
325
# Break if stop thread activated
321
- if self ._stop_thread . is_set () and i != self ._iteration - 1 :
326
+ if self .interrupted and i != self ._iteration - 1 :
322
327
msg = 'The stop mecanism has been activated during Run'
323
328
msg += ' (execution {})' .format (i + 1 )
324
329
self .warning (msg )
@@ -327,7 +332,7 @@ def execute(self, stop_thread, log_dict):
327
332
self ._valid_run_count += 1
328
333
sleep (self ._tick )
329
334
# Break if stop thread activated
330
- if self ._stop_thread . is_set () and i != self ._iteration - 1 :
335
+ if self .interrupted and i != self ._iteration - 1 :
331
336
msg = 'The stop mecanism has been activated during Run'
332
337
msg += ' (tick {})' .format (i + 1 )
333
338
self .warning (msg )
0 commit comments