def __init__(self, config, workerClass=Worker): AbstractBatchSystem.__init__(self, config) #Call the parent constructor self.jobIndex = 0 self.jobs = {} self.maxThreads = int(config.attrib["max_threads"]) assert self.maxThreads >= 1 self.inputQueue = Queue() self.outputQueue = Queue() for i in xrange(int(config.attrib["max_threads"])): #Setup the threads worker = workerClass(self.inputQueue, self.outputQueue) worker.setDaemon(True) worker.start()
def __init__(self, config): AbstractBatchSystem.__init__(self, config) #Call the parent constructor self.gridengineResultsFile = config.attrib["results_file"] #Reset the job queue and results (initially, we do this again once we've killed the jobs) self.gridengineResultsFileHandle = open(self.gridengineResultsFile, 'w') self.gridengineResultsFileHandle.close() #We lose any previous state in this file, and ensure the files existence self.scratchFile = self.config.attrib["scratch_file"] self.currentjobs = set() self.obtainSystemConstants() self.jobIDs = dict() self.sgeJobIDs = dict() self.nextJobID = 0 self.newJobsQueue = Queue() self.updatedJobsQueue = Queue() self.worker = Worker(self.newJobsQueue, self.updatedJobsQueue, self) self.worker.setDaemon(True) self.worker.start()
def __init__(self, config): AbstractBatchSystem.__init__(self, config) #Call the parent constructor #Keep the name of the results file for the pstat2 command.. self.parasolResultsFile = config.attrib["results_file"] #Reset the job queue and results (initially, we do this again once we've killed the jobs) self.parasolResultsFileHandle = open(self.parasolResultsFile, 'w') self.parasolResultsFileHandle.close() #We lose any previous state in this file, and ensure the files existence self.queuePattern = re.compile("q\s+([0-9]+)") self.runningPattern = re.compile("r\s+([0-9]+)\s+[\S]+\s+[\S]+\s+([0-9]+)\s+[\S]+") #The scratch file self.scratchFile = self.config.attrib["scratch_file"] self.killJobs(self.getIssuedJobIDs()) #Kill any jobs on the current stack logger.info("Going to sleep for a few seconds to kill any existing jobs") time.sleep(5) #Give batch system a second to sort itself out. logger.info("Removed any old jobs from the queue") #Reset the job queue and results self.parasolResultsFileHandle = open(self.parasolResultsFile, 'w') self.parasolResultsFileHandle.close() #We lose any previous state in this file, and ensure the files existence self.parasolResultsFileHandle = open(self.parasolResultsFile, 'r') logger.info("Reset the results queue")