GUI more responsive while experiment is queued and queued experiment can be stopped.

This commit is contained in:
Joachim Beerwerth 2018-04-09 16:43:21 +02:00
parent 591cf8bdea
commit 3a81893a25

View File

@ -197,6 +197,9 @@ class DamarisGUI:
# lock file to prevent other DAMARIS to start immediatly
self.lockfile = LockFile() # = os.path.expanduser("~/.damaris.lock")
self.id = None
#to stop queued experiments
self.stop_experiment_flag = threading.Event()
exp_script = u""
if exp_script_filename is not None and exp_script_filename != "":
@ -454,10 +457,13 @@ class DamarisGUI:
self.log.textbuffer.create_mark( "lastdumped", self.log.textbuffer.get_end_iter( ), left_gravity=True )
loop_run=0
interval = 2
#user shorter interval because this blocks user events from the GUI
interval = 0.1
self.stop_experiment_flag.clear()
self.id = self.lockfile.add_experiment()
while not self.lockfile.am_i_next():
time.sleep(interval)
while not self.lockfile.am_i_next() and not self.stop_experiment_flag.isSet():
self.stop_experiment_flag.wait(interval)
while gtk.events_pending():
gtk.main_iteration(False)
if loop_run > 1:
@ -937,6 +943,7 @@ class DamarisGUI:
def stop_experiment( self, widget, data=None ):
if self.state in [ DamarisGUI.Run_State, DamarisGUI.Pause_State ]:
self.stop_experiment_flag.set()
if self.si is None:
return
still_running = filter( None, [ self.si.exp_handling, self.si.res_handling, self.si.back_driver ] )