Queueing works now with more than 2 queued experiments
This commit is contained in:
parent
7280a9aba3
commit
58515f1cf3
@ -18,6 +18,7 @@ import xdg.BaseDirectory
|
||||
# import 3rd party modules
|
||||
# gui graphics
|
||||
import gobject
|
||||
import glob
|
||||
|
||||
gobject.threads_init( )
|
||||
import pygtk
|
||||
@ -80,7 +81,7 @@ from damaris.data import DataPool, Accumulation, ADC_Result, MeasurementResult
|
||||
debug = False
|
||||
|
||||
# version info
|
||||
__version__ = "0.15-0-$Revision$"
|
||||
__version__ = "0.18-0-$Revision$"
|
||||
|
||||
|
||||
class logstream:
|
||||
@ -115,6 +116,30 @@ BackendDriver.log = log
|
||||
DataPool.log = log
|
||||
|
||||
|
||||
class LockFile:
|
||||
def __init__(self):
|
||||
self.index = 0
|
||||
self.templ = os.path.expanduser("~/.damaris.lock")
|
||||
self.existing = []
|
||||
self._lockfile = self.lockfile(self.index)
|
||||
self.has_lockfile = None
|
||||
|
||||
def lockfile(self, idx):
|
||||
return "%s.%i"%(self.templ, idx)
|
||||
|
||||
def get_lockfile(self):
|
||||
#self._lockfile = self.lockfile()
|
||||
while os.path.exists(self._lockfile):
|
||||
self.existing.append(self._lockfile)
|
||||
self.index += 1
|
||||
self._lockfile = self.lockfile(self.index)
|
||||
print self._lockfile
|
||||
self.has_lockfile = self._lockfile
|
||||
|
||||
def no_lockfiles(self):
|
||||
return glob.glob("%s.*"%self.templ) == []
|
||||
|
||||
|
||||
class DamarisGUI:
|
||||
ExpScript_Display = 0
|
||||
ResScript_Display = 1
|
||||
@ -157,7 +182,7 @@ class DamarisGUI:
|
||||
|
||||
self.config = ConfigTab( self.xml_gui )
|
||||
# lock file to prevent other DAMARIS to start immediatly
|
||||
self.lockfile = os.path.expanduser("~/.damaris.lock")
|
||||
self.lockfile = LockFile() # = os.path.expanduser("~/.damaris.lock")
|
||||
|
||||
exp_script = u""
|
||||
if exp_script_filename is not None and exp_script_filename != "":
|
||||
@ -414,14 +439,18 @@ class DamarisGUI:
|
||||
# only observe lock file if you want to start immediatly after start up
|
||||
if self.start_immediatly:
|
||||
loop_run=0
|
||||
while os.path.exists(self.lockfile):
|
||||
time.sleep(0.2)
|
||||
interval = 2
|
||||
self.lockfile.get_lockfile()
|
||||
while not self.lockfile.no_lockfiles():
|
||||
time.sleep(interval)
|
||||
while gtk.events_pending():
|
||||
gtk.main_iteration(False)
|
||||
if loop_run%10==0:
|
||||
self.experiment_script_statusbar_label.set_text("Waiting for other experiment to finish (Lockfile: %s)" % self.lockfile)
|
||||
print "Lockfile still exists, waiting ... (%s)" % self.lockfile
|
||||
loop_run += 1
|
||||
if loop_run > 2:
|
||||
self.experiment_script_statusbar_label.set_text("Waiting for other experiment to finish (My lockfile: %s)" % self.lockfile.has_lockfile)
|
||||
loop_run = 0
|
||||
print "Lockfile still exists, waiting ... (%s)" % self.lockfile.has_lockfile
|
||||
loop_run += interval
|
||||
|
||||
# start experiment
|
||||
try:
|
||||
self.spool_dir = os.path.abspath( actual_config[ "spool_dir" ] )
|
||||
@ -472,8 +501,8 @@ class DamarisGUI:
|
||||
self.main_notebook.set_current_page( DamarisGUI.Monitor_Display )
|
||||
|
||||
# create lock file
|
||||
print "Creating lockfile %s"%self.lockfile
|
||||
lfile = open(self.lockfile, "w").close()
|
||||
print "Creating lockfile %s"%self.lockfile.has_lockfile
|
||||
lfile = open(self.lockfile.has_lockfile, "w").close()
|
||||
# set running
|
||||
if self.si.exp_handling is not None:
|
||||
self.experiment_script_statusbar_label.set_text( "Experiment Script Running (0)" )
|
||||
@ -621,9 +650,9 @@ class DamarisGUI:
|
||||
# keep data to display but throw away everything else
|
||||
self.si = None
|
||||
# delete locak file so that other experiment can start
|
||||
if os.path.exists(self.lockfile):
|
||||
if os.path.exists(self.lockfile.has_lockfile):
|
||||
try:
|
||||
os.remove(self.lockfile)
|
||||
os.remove(self.lockfile.has_lockfile)
|
||||
except:
|
||||
raise IOError("Could not remove lock file: %s"%self.lockfile)
|
||||
return False
|
||||
|
Loading…
Reference in New Issue
Block a user