def _loopUpdatePipelineChildren(self): if self.stateF == self.STATE_WAITING_TO_RESTART: self._log('Pipeline waiting to restart') if self.pipelineState == tasks_tx.task.TASK_FAILED: self._log('Pipeline waiting to restart in failed state, restarting') yield pipeline_run.resume(self.requestState, self.pipeline) self.stateF = self.STATE_IDLE self.changed('state', self.state()) self._log('Restarted, moving to idle state') else: self._log('Pipeline waiting to restart, not in failed state, waiting longer') self.delayed = reactor.callLater(PIPELINE_UPDATE_FREQUENCY, self.delayedLock.run, self._updatePipelineChildren) elif self.stateF == self.STATE_RUNNING and self.pipelineState in [tasks_tx.task.TASK_FAILED, tasks_tx.task.TASK_COMPLETED]: self._log('Pipeline in running stated but failed or completed, unsubscribing %s' % self.pipelineState) self.stateF = self.STATE_COMPLETED if self.pipelineState == tasks_tx.task.TASK_COMPLETED else self.STATE_FAILED self.changed('state', self.state()) elif self.pipelineState not in [tasks_tx.task.TASK_FAILED, tasks_tx.task.TASK_COMPLETED]: self._log('Looping') # Call ourselves again if the pipeline is not finished and the delayed call hasn't already been # cancelled self.delayed = reactor.callLater(PIPELINE_UPDATE_FREQUENCY, self.delayedLock.run, self._updatePipelineChildren)
def _loopUpdatePipelineChildren(self): if self.stateF == self.STATE_WAITING_TO_RESTART: self._log('Pipeline waiting to restart') if self.pipelineState == tasks_tx.task.TASK_FAILED: self._log( 'Pipeline waiting to restart in failed state, restarting') yield pipeline_run.resume(self.requestState, self.pipeline) self.stateF = self.STATE_IDLE self.changed('state', self.state()) self._log('Restarted, moving to idle state') else: self._log( 'Pipeline waiting to restart, not in failed state, waiting longer' ) self.delayed = reactor.callLater(PIPELINE_UPDATE_FREQUENCY, self.delayedLock.run, self._updatePipelineChildren) elif self.stateF == self.STATE_RUNNING and self.pipelineState in [ tasks_tx.task.TASK_FAILED, tasks_tx.task.TASK_COMPLETED ]: self._log( 'Pipeline in running stated but failed or completed, unsubscribing %s' % self.pipelineState) self.stateF = self.STATE_COMPLETED if self.pipelineState == tasks_tx.task.TASK_COMPLETED else self.STATE_FAILED self.changed('state', self.state()) elif self.pipelineState not in [ tasks_tx.task.TASK_FAILED, tasks_tx.task.TASK_COMPLETED ]: self._log('Looping') # Call ourselves again if the pipeline is not finished and the delayed call hasn't already been # cancelled self.delayed = reactor.callLater(PIPELINE_UPDATE_FREQUENCY, self.delayedLock.run, self._updatePipelineChildren)
def resumePipeline(request, pipeline): runningPipeline = yield pipeline_run.resume(request.state, pipeline) pipelineMonitor = pipeline_monitor.PipelineMonitor(request.state, request.mq, runningPipeline, int(request.state.conf('pipelines.retries'))) if request.state.pipelinesMonitor.contains(pipelineMonitor): oldPipelineMonitor = request.state.pipelinesMonitor.remove(pipelineMonitor) oldPipelineMonitor.release() yield pipelineMonitor.initialize() pipelineMonitor = request.state.pipelinesMonitor.add(pipelineMonitor) taskResumePipeline = TaskResumePipeline(request.state.pipelinesCache, pipelineMonitor) taskResumePipeline.initialize() defer.returnValue(pipelineMonitor)