def __init__(self, deferred, listener, clock=None): """Construct an instance of the protocol, for listening to a worker. :param deferred: A Deferred that will be fired when the worker has finished (either successfully or unsuccesfully). :param listener: A PullerMaster object that is notified when the protocol receives events from the worker. :param clock: A provider of Twisted's IReactorTime. This parameter exists to allow testing that does not depend on an external clock. If a clock is not passed in explicitly the reactor is used. """ ProcessMonitorProtocolWithTimeout.__init__( self, deferred, config.supermirror.worker_timeout, clock) self.reported_mirror_finished = False self.listener = listener self.wire_protocol = PullerWireProtocol(self) self._stderr = StringIO() self._deferred.addCallbacks(self.checkReportingFinishedAndNoStderr, self.ensureReportingFinished)
def __init__(self, deferred, worker_monitor, log_file, clock=None): """Construct an instance. :param deferred: See `ProcessMonitorProtocol.__init__` -- the deferred that will be fired when the process has exited. :param worker_monitor: A `CodeImportWorkerMonitor` instance. :param log_file: A file object that the output of the child process will be logged to. :param clock: A provider of Twisted's IReactorTime. This parameter exists to allow testing that does not depend on an external clock. If a clock is not passed in explicitly the reactor is used. """ ProcessMonitorProtocolWithTimeout.__init__( self, deferred, clock=clock, timeout=config.codeimport.worker_inactivity_timeout) self.worker_monitor = worker_monitor self._tail = '' self._log_file = log_file self._looping_call = task.LoopingCall(self._updateHeartbeat) self._looping_call.clock = self._clock
def __init__(self, deferred, listener, clock=None): """Construct an instance of the protocol, for listening to a worker. :param deferred: A Deferred that will be fired when the worker has finished (either successfully or unsuccesfully). :param listener: A PullerMaster object that is notified when the protocol receives events from the worker. :param clock: A provider of Twisted's IReactorTime. This parameter exists to allow testing that does not depend on an external clock. If a clock is not passed in explicitly the reactor is used. """ ProcessMonitorProtocolWithTimeout.__init__( self, deferred, config.supermirror.worker_timeout, clock) self.reported_mirror_finished = False self.listener = listener self.wire_protocol = PullerWireProtocol(self) self._stderr = StringIO() self._deferred.addCallbacks( self.checkReportingFinishedAndNoStderr, self.ensureReportingFinished)