def run(self):
self._logger.debug("<STR_LIT>" % (self._modelID))<EOL>periodic = self._initPeriodicActivities()<EOL>self._optimizedMetricLabel = self._optimizeKeyPattern<EOL>self._reportMetricLabels = [self._optimizeKeyPattern]<EOL>if self._iterations >= <NUM_LIT:0>:<EOL><INDENT>iterTracker = iter(xrange(self._iterations))<EOL><DEDENT>else:<EOL><INDENT>iterTracker = iter(itertools.count())<EOL><DEDENT>doSysExit = False<EOL>if self._sysExitModelRange is not None:<EOL><INDENT>modelAndCounters = self._jobsDAO.modelsGetUpdateCounters(self._jobID)<EOL>modelIDs = [x[<NUM_LIT:0>] for x in modelAndCounters]<EOL>modelIDs.sort()<EOL>(beg,end) = self._sysExitModelRange<EOL>if self._modelID in modelIDs[int(beg):int(end)]:<EOL><INDENT>doSysExit = True<EOL><DEDENT><DEDENT>if self._delayModelRange is not None:<EOL><INDENT>modelAndCounters = self._jobsDAO.modelsGetUpdateCounters(self._jobID)<EOL>modelIDs = [x[<NUM_LIT:0>] for x in modelAndCounters]<EOL>modelIDs.sort()<EOL>(beg,end) = self._delayModelRange<EOL>if self._modelID in modelIDs[int(beg):int(end)]:<EOL><INDENT>time.sleep(<NUM_LIT:10>)<EOL><DEDENT><DEDENT>if self._errModelRange is not None:<EOL><INDENT>modelAndCounters = self._jobsDAO.modelsGetUpdateCounters(self._jobID)<EOL>modelIDs = [x[<NUM_LIT:0>] for x in modelAndCounters]<EOL>modelIDs.sort()<EOL>(beg,end) = self._errModelRange<EOL>if self._modelID in modelIDs[int(beg):int(end)]:<EOL><INDENT>raise RuntimeError("<STR_LIT>")<EOL><DEDENT><DEDENT>if self._delay is not None:<EOL><INDENT>time.sleep(self._delay)<EOL><DEDENT>self._currentRecordIndex = <NUM_LIT:0><EOL>while True:<EOL><INDENT>if self._isKilled:<EOL><INDENT>break<EOL><DEDENT>if self._isCanceled:<EOL><INDENT>break<EOL><DEDENT>if self._isMature:<EOL><INDENT>if not self._isBestModel:<EOL><INDENT>self._cmpReason = self._jobsDAO.CMPL_REASON_STOPPED<EOL>break<EOL><DEDENT>else:<EOL><INDENT>self._cmpReason = self._jobsDAO.CMPL_REASON_EOF<EOL><DEDENT><DEDENT>try:<EOL><INDENT>self._currentRecordIndex = next(iterTracker)<EOL><DEDENT>except StopIteration:<EOL><INDENT>break<EOL><DEDENT>self._writePrediction(ModelResult(None, None, None, None))<EOL>periodic.tick()<EOL>if self.__shouldSysExit(self._currentRecordIndex):<EOL><INDENT>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>if self._busyWaitTime is not None:<EOL><INDENT>time.sleep(self._busyWaitTime)<EOL>self.__computeWaitTime()<EOL><DEDENT>if doSysExit:<EOL><INDENT>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>if self._jobFailErr:<EOL><INDENT>raise utils.JobFailException("<STR_LIT>",<EOL>"<STR_LIT>")<EOL><DEDENT><DEDENT>if self._doFinalize:<EOL><INDENT>if not self._makeCheckpoint:<EOL><INDENT>self._model = None<EOL><DEDENT>if self._finalDelay is not None:<EOL><INDENT>time.sleep(self._finalDelay)<EOL><DEDENT>self._finalize()<EOL><DEDENT>self._logger.info("<STR_LIT>"% (self._modelID))<EOL>return (self._cmpReason, None)<EOL>
Runs the given OPF task against the given Model instance