def processEnded(self, reason):
"""Fire back the deferred.
The deferred will be fired with the string of data received from the
subprocess, or if the subprocess was cancelled, a
L{ProcessTimeLimitReachedError} will be fired with data accumulated so
far.
"""
exit_code = reason.value.exitCode
# We get bytes with self.data, but want unicode with replace
# characters. This is again attempted in
# ScriptExecutionPlugin._respond, but it is not called in all cases.
data = b"".join(self.data).decode("utf-8", "replace")
if self._cancelled:
self.result_deferred.errback(ProcessTimeLimitReachedError(data))
else:
if self._scheduled_cancel is not None:
scheduled = self._scheduled_cancel
self._scheduled_cancel = None
self.reactor.cancel_call(scheduled)
if reason.check(ProcessDone):
self.result_deferred.callback(data)
else:
self.result_deferred.errback(
ProcessFailedError(data, exit_code))
评论列表
文章目录