Part of lp.codehosting.codeimport.workermonitor View In Hierarchy
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||_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.|
|Method||runNotification||Run a given function in series with other notifications.|
|Method||unexpectedError||Something's gone wrong: kill the subprocess and report failure.|
|Method||terminateProcess||Terminate the process by SIGINT initially, but SIGKILL if needed.|
|Method||_sigkill||Forcefully kill the process.|
|log_file||A file object that the output of the child process will be logged to.|
|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.|
We call updateHeartbeat for the first time when we are connected to the process and every config.codeimportworker.heartbeat_update_interval seconds thereafter.
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.
Any output resets the timeout, is stored in the logfile and updates the tail of the log.
We stop updating the heartbeat when the process exits.