Skip to content

Commit

Permalink
proper waiting for elasticbu.py and move object out of scope so that
Browse files Browse the repository at this point in the history
kill cannot be attempted on shutdown (e.g. after many weeks)
  • Loading branch information
smorovic committed Mar 9, 2015
1 parent e99a43a commit b9d9405
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions python/elasticbu.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,9 @@ def stop(self):

class RunCompletedChecker(threading.Thread):

def __init__(self,conf,mode,nr,nresources,run_dir,active_runs,active_runs_errors,elastic_process):
def __init__(self,conf,mode,nr,nresources,run_dir,active_runs,active_runs_errors,parent):
self.logger = logging.getLogger(self.__class__.__name__)
self.parent = parent
self.conf=conf
self.mode = mode
self.nr = nr
Expand All @@ -585,7 +586,6 @@ def __init__(self,conf,mode,nr,nresources,run_dir,active_runs,active_runs_errors
self.run_dir = run_dir
self.active_runs = active_runs
self.active_runs_errors = active_runs_errors
self.elastic_process=elastic_process
try:
threading.Thread.__init__(self)

Expand Down Expand Up @@ -642,6 +642,11 @@ def checkBoxes(self,dir):
if endAllowed==True and runFound==False: return False
else:return True

def waitForAnelasticMon(self):
try:
self.parent.elastic_process.wait()
except:pass
self.parent.elastic_process = None

def run(self):

Expand All @@ -650,10 +655,12 @@ def run(self):
self.threadEvent.wait(5)
if self.stop:
try:
self.elastic_process.wait()
self.waitForAnelasticMon()
except:pass
return#giving up
if os.path.exists(self.eorCheckPath) or os.path.exists(self.rundirCheckPath)==False:
self.waitForAnelasticMon()
self.logger.info('finished waiting for elastic process')
break

dir = self.conf.resource_base+'/boxes/'
Expand Down Expand Up @@ -723,10 +730,6 @@ def run(self):
#check every 10 seconds
self.threadEvent.wait(10)

try:
self.elastic_process.wait()
except:pass

def stop(self):
self.stop = True
self.threadEvent.set()
Expand Down
2 changes: 1 addition & 1 deletion python/hltd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1655,7 +1655,7 @@ def startCompletedChecker(self):
logger.info('start checking completition of run '+str(self.runnumber))
#mode 1: check for complete entries in ES
#mode 2: check for runs in 'boxes' files
self.endChecker = RunCompletedChecker(conf,1,int(self.runnumber),self.online_resource_list,self.dirname,active_runs,active_runs_errors,self.elastic_monitor)
self.endChecker = RunCompletedChecker(conf,1,int(self.runnumber),self.online_resource_list,self.dirname,active_runs,active_runs_errors,self)
self.endChecker.start()
except Exception,ex:
logger.error('failure to start run completition checker:')
Expand Down

0 comments on commit b9d9405

Please sign in to comment.