def _feed_error(self, s): self._append_chunk_to_window(self.error_output, s) cmd_logger.debug('pid {}: stderr feed, {} bytes'.format(self.subprocess.pid, len(s)), extra=self.log_extra) self.error_output_size = min(self.OUTPUT_WINDOW_SIZE, self.error_output_size + len(s)) self._update_db_dump() if len(s) == 0: # this is the last chunk self.error_output_closed = True self._complete_if_ready()
def _ensure_exit_cb(self): if self._exit: return if self._force_complete_cb_timeout is None: cmd_logger.debug('pid {0}: setting force complete callback'.format(self.subprocess.pid), extra=self.log_extra) self._force_complete_cb_timeout = self.subprocess.io_loop.add_timeout( datetime.timedelta(seconds=10), self._force_complete, )
def _complete_if_ready(self): if not self._exit: return if not self.output_closed: return if not self.error_output_closed: return if self._force_complete_cb_timeout: cmd_logger.debug('pid {0}: removing force complete callback'.format(self.subprocess.pid), extra=self.log_extra) self.subprocess.io_loop.remove_timeout(self._force_complete_cb_timeout) self._force_complete_cb_timeout = None cmd_logger.info('pid {0}: command execution is completed'.format(self.subprocess.pid), extra=self.log_extra) self.command.on_command_completed()
def _exit_cb(self, code): self._exit = True cmd_logger.debug('pid {0}: exit callback'.format(self.subprocess.pid), extra=self.log_extra) self.exit_code = code self.progress = 1.0 self.set_command_code() cmd_logger.info('pid {0}: exit code {1}, command code {2}'.format( self.subprocess.pid, self.exit_code, self.command_code), extra=self.log_extra) if self._force_complete_cb_timeout is None: cmd_logger.debug('pid {0}: setting force complete callback '.format(self.subprocess.pid), extra=self.log_extra) self._force_complete_cb_timeout = self.subprocess.io_loop.add_timeout( datetime.timedelta(seconds=10), self._force_complete, ) self._complete_if_ready()