def __startComponent(self): if not self.isStarted(): return utils.cancelTimeout(self._delayed) self._delayed = None if self._pendingName: self.log("Canceling component startup for task '%s', " "component '%s' is pending", self.label, self._pendingName) return if not self._workerPxy: self.warning("Couldn't start component for task '%s', " "no worker found", self.label) return compPxy = self.getActiveComponent() if compPxy: workerPxy = compPxy.getWorkerProxy() if workerPxy == self._workerPxy: self.debug("The valid component '%s' is already started", compPxy.getName()) return # Set the pendingName right now to prevent other # transoder to be started self._pendingName = utils.genUniqueIdentifier() self.log("Admin task '%s' is looking for a potential component", self.label) # Check there is a valid transcoder already running d = self.__waitPotentialComponent(self.POTENTIAL_TIMEOUT) d.addCallbacks(self.__cbGotPotentialComponent, self.__ebPotentialComponentFailure)
def _cancelComponentHold(self): if self._holdTimeout == None: return compPxy = self.getActiveComponent() self.log("Admin task '%s' cancel the lost component '%s' hold", self.label, compPxy.getName()) utils.cancelTimeout(self._holdTimeout) self._holdTimeout = None self._onComponentHoldCanceled(compPxy)
def _discoverer_callback(self, discoverer, is_media): if not (discoverer in self._pending): # Analyse timed out before completion return filePath, deferred, to = self._pending.pop(discoverer) utils.cancelTimeout(to) if is_media: deferred.callback(MediaAnalysis(filePath, discoverer)) else: msg = "Analyzed file is not a known media type" error = MediaAnalysisUnknownTypeError(msg, filePath) deferred.errback(error)
def __onComponentMoodChanged(self, transPxy, mood): if not self.isStarted(): return self.log("Transcoding task '%s' transcoder '%s' goes %s", self.label, transPxy.getName(), mood.name) if self._isPendingComponent(transPxy): # Currently beeing started up return if self._isElectedComponent(transPxy): if mood != moods.sad: utils.cancelTimeout(self._sadTimeout) if mood == moods.happy: if self._isHoldingLostComponent(): self._restoreLostComponent(transPxy) return if mood == moods.sad: if not transPxy.isRunning(): # The transcoder has been killed or segfaulted self._processInterruptionDetected() self._abort() return # The transcoder can be a zombie or waiting for acknowledge. # Timeout to prevent the task to stall. timeout = adminconsts.TRANSCODER_SAD_TIMEOUT to = utils.createTimeout(timeout, self.__asyncSadTimeout, transPxy) self._sadTimeout = to return self.warning( "Transcoding task '%s' selected transcoder '%s' " "gone %s", self.label, transPxy.getName(), mood.name ) if mood == moods.lost: # If the transcoder goes lost, wait a fixed amount of time # to cope with small transient failures. self._holdLostComponent(transPxy) return self._abort() if mood == moods.waking: # Keep the waking components return if mood == moods.sleeping: self._deleteComponent(transPxy) return # If no transcoder is selected, don't stop any happy monitor if (not self._hasElectedComponent()) and (mood == moods.happy): return self._stopComponent(transPxy)
def __cbPostAcceptAddition(self, accepted, compPxy): identifier = compPxy.identifier assert not (identifier in self._rejecteds) if accepted: self._doAddComponent(compPxy) if identifier in self._compWaiters: for d, to in self._compWaiters[identifier].items(): utils.cancelTimeout(to) d.callback(compPxy) del self._compWaiters[identifier] else: self._rejecteds[identifier] = compPxy self._doRejectComponent(compPxy) if identifier in self._compWaiters: for d, to in self._compWaiters[identifier].items(): utils.cancelTimeout(to) d.errback(admerrs.ComponentRejectedError("Component rejected")) del self._compWaiters[identifier]
def __onPipelinePrerolled(self): self.log("Thumbnailing pipeline '%s' prerolled", self._getTranscodingTag()) utils.cancelTimeout(self._prerollTimeout)
def __onPipelineError(self, message, debug): self.log("Thumbnailing pipeline '%s' error: %s", self._getTranscodingTag(), message) utils.cancelTimeout(self._playErrorTimeout) msg = "Thumbnailing pipeline error: " + message self.__postError(msg, debug)
def _onComponentRelieved(self, compPxy): # If elected component is relieved we cannot be acknowledging anymore self._acknowledging = False utils.cancelTimeout(self._sadTimeout) self.emit("component-released", compPxy)
def __ebComponentLoadingFailed(self, failure, identifier, initDef, resultDef, to): utils.cancelTimeout(to) self._waitCompLoaded.pop(identifier, None) resultDef.errback(failure)
def __cbComponentLoaded(self, compState, identifier, initDef, resultDef, to): utils.cancelTimeout(to) initDef.chainDeferred(resultDef)