preliminary work for queued experiments

This commit is contained in:
Markus Rosenstihl 2018-03-20 18:16:09 +01:00
parent 8991e61600
commit 84dd157f08
3 changed files with 23 additions and 7 deletions

View File

@ -156,6 +156,8 @@ class DamarisGUI:
self.monitor = MonitorWidgets( self.xml_gui ) self.monitor = MonitorWidgets( self.xml_gui )
self.config = ConfigTab( self.xml_gui ) self.config = ConfigTab( self.xml_gui )
# lock file to prevent other DAMARIS to start immediatly
self.lockfile = os.path.expanduser("~/.damaris.lock")
exp_script = u"" exp_script = u""
if exp_script_filename is not None and exp_script_filename != "": if exp_script_filename is not None and exp_script_filename != "":
@ -349,7 +351,7 @@ class DamarisGUI:
self.sw.enable_editing( ) self.sw.enable_editing( )
return return
# check whether scripts are syntacticaly valid # check whether scripts are syntactically valid
# should be merged with check script function # should be merged with check script function
exp_code = None exp_code = None
if exp_script != "": if exp_script != "":
@ -408,7 +410,13 @@ class DamarisGUI:
# set the text mark for hdf logging # set the text mark for hdf logging
if self.log.textbuffer.get_mark( "lastdumped" ) is None: if self.log.textbuffer.get_mark( "lastdumped" ) is None:
self.log.textbuffer.create_mark( "lastdumped", self.log.textbuffer.get_end_iter( ), left_gravity=True ) self.log.textbuffer.create_mark( "lastdumped", self.log.textbuffer.get_end_iter( ), left_gravity=True )
# only observe lock file if you want to start immediatly after start up
if self.start_immediatly:
while os.path.exists(self.lockfile):
time.sleep(0.2)
gtk.main_iteration()
self.experiment_script_statusbar_label.set_text("Waiting for other experiment to finish ... (Loackfile: %s)" % self.lockfile)
print "Lockfile still exists, waiting ... (%s)" % self.lockfile
# start experiment # start experiment
try: try:
self.spool_dir = os.path.abspath( actual_config[ "spool_dir" ] ) self.spool_dir = os.path.abspath( actual_config[ "spool_dir" ] )
@ -458,6 +466,9 @@ class DamarisGUI:
# switch to grapics # switch to grapics
self.main_notebook.set_current_page( DamarisGUI.Monitor_Display ) self.main_notebook.set_current_page( DamarisGUI.Monitor_Display )
# create lock file
print "Creating lockfile %s"%self.lockfile
lfile = open(self.lockfile, "w").close()
# set running # set running
if self.si.exp_handling is not None: if self.si.exp_handling is not None:
self.experiment_script_statusbar_label.set_text( "Experiment Script Running (0)" ) self.experiment_script_statusbar_label.set_text( "Experiment Script Running (0)" )
@ -604,7 +615,12 @@ class DamarisGUI:
# keep data to display but throw away everything else # keep data to display but throw away everything else
self.si = None self.si = None
# delete locak file so that other experiment can start
if os.path.exists(self.lockfile):
try:
os.remove(self.lockfile)
except:
raise IOError("Could not remove lock file: %s"%self.lockfile)
return False return False
# dump states? # dump states?
@ -3135,7 +3151,7 @@ class ScriptInterface:
self.exp_writer = self.res_reader = self.back_driver = None self.exp_writer = self.res_reader = self.back_driver = None
if self.backend_executable is not None and self.backend_executable != "": if self.backend_executable is not None and self.backend_executable != "":
self.back_driver = BackendDriver.BackendDriver( self.backend_executable, spool_dir, clear_jobs, self.back_driver = BackendDriver.BackendDriver( self.backend_executable, spool_dir, clear_jobs,
clear_results ) clear_results)
if self.exp_script: if self.exp_script:
self.exp_writer = self.back_driver.get_exp_writer( ) self.exp_writer = self.back_driver.get_exp_writer( )
if self.res_script: if self.res_script:

View File

@ -7,5 +7,5 @@ def test():
return e return e
def experiment(): def experiment():
for i in range(1): for i in range(1000):
yield test() yield test()

View File

@ -1,4 +1,4 @@
def result(): def result():
for num,ts in enumerate(results): for num,ts in enumerate(results):
data["ts %i"%num] = ts data["ts %i"%num] = ts
print ts #print ts