l.c.c.w.CodeImportWorkerMonitorProtocol(ProcessMonitorProtocolWithTimeout) : class documentation

Part of lp.codehosting.codeimport.workermonitor View In Hierarchy

Known subclasses: lp.codehosting.codeimport.tests.test_workermonitor.CIWorkerMonitorProtocolForTesting

The protocol by which the child process talks to the monitor.

In terms of bytes, the protocol is extremely simple: any output is stored in the log file and seen as timeout-resetting activity. Every config.codeimportworker.heartbeat_update_interval seconds we ask the monitor to update the heartbeat of the job we are working on and pass the tail of the log output.

Method __init__ Construct an instance.
Method connectionMade See BaseProtocol.connectionMade.
Method outReceived See ProcessProtocol.outReceived.
Method processEnded See ProcessMonitorProtocolWithTimeout.processEnded.
Method _updateHeartbeat Ask the monitor to update the heartbeat.

Inherited from ProcessMonitorProtocolWithTimeout:

Method callLater Override TimeoutMixin.callLater so we use self._clock.
Method timeoutConnection When a timeout occurs, kill the process and record a TimeoutError.

Inherited from ProcessMonitorProtocol (via ProcessMonitorProtocolWithTimeout):

Method runNotification Run a given function in series with other notifications.
Method unexpectedError Something's gone wrong: kill the subprocess and report failure.

Inherited from ProcessProtocolWithTwoStageKill (via ProcessMonitorProtocolWithTimeout, ProcessMonitorProtocol):

Method terminateProcess Terminate the process by SIGINT initially, but SIGKILL if needed.
Method _sigkill Forcefully kill the process.
def __init__(self, deferred, worker_monitor, log_file, clock=None):
Construct an instance.
ParametersdeferredSee ProcessMonitorProtocol.__init__ -- the deferred that will be fired when the process has exited.
worker_monitorA CodeImportWorkerMonitor instance.
log_fileA file object that the output of the child process will be logged to.
clockA 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.
def connectionMade(self):
See BaseProtocol.connectionMade.

We call updateHeartbeat for the first time when we are connected to the process and every config.codeimportworker.heartbeat_update_interval seconds thereafter.

def _updateHeartbeat(self):
Ask the monitor to update the heartbeat.

We use runNotification() to serialize the updates and ensure that any errors are handled properly. We do not return the deferred, as we want this function to be called at a frequency independent of how long it takes to update the heartbeat.

def outReceived(self, data):
See ProcessProtocol.outReceived.

Any output resets the timeout, is stored in the logfile and updates the tail of the log.

def processEnded(self, reason):
See ProcessMonitorProtocolWithTimeout.processEnded.

We stop updating the heartbeat when the process exits.

API Documentation for Launchpad, generated by pydoctor at 2019-09-23 00:00:04.