Mark the process as complete with provided return_code
325795
def complete(self, return_code):
        
        self.return_code = return_code
        self.status = 'COMPLETE' if not return_code else 'FAILED'
        self.end_time = datetime.datetime.now()
1036011
def exitcode(self):
        
        if self._process is None:
            raise ProcessError(
                "Process '%s' has not been started yet" % self.name)
        return self._process.exitcode
255282
def check_complete(self):
        
        logger.debug('Running check_complete for task {0}'.format(self.name))

        # Tasks not completed
        if self.remote_not_complete() or self.local_not_complete():
            self._start_check_timer()
            return

        return_code = self.completed_task()

        # Handle task errors
        if self.terminate_sent:
            self.stderr += '\nDAGOBAH SENT SIGTERM TO THIS PROCESS\n'
        if self.kill_sent:
            self.stderr += '\nDAGOBAH SENT SIGKILL TO THIS PROCESS\n'
        if self.remote_failure:
            return_code = -1
            self.stderr += '\nAn error occurred with the remote machine.\n'

        self.stdout_file = None
        self.stderr_file = None

        self._task_complete(success=True if return_code == 0 else False,
                            return_code=return_code,
                            stdout=self.stdout,
                            stderr=self.stderr,
                            start_time=self.started_at,
                            complete_time=datetime.utcnow())
605163
function (code, args, done) {
  var pyg = spawn(bin, args.toArray()),
      out = [],
      failed = false;

  pyg.on('error', function() {
    failed = true;
    done.apply(this, arguments);
  })

  pyg.stdout.setEncoding('utf8');
  pyg.stderr.setEncoding('utf8');

  var pusher = function(data) {
    out.push(data.toString());
  }

  pyg.stdout.on('data', pusher);
  pyg.stderr.on('data', pusher);

  pyg.on('exit', function (status) {
    // Return if done already called
    if(failed)
      return

    // pygmentize was successful
    if(status == 0)
      return done(null, out.join(''));

    // pygmentize was unsuccessful (cli error?)
    return done(out.join(''));
  });

  pyg.stdin.write(code);
  pyg.stdin.end();

}
1222297
def _termination_callback(self, process_name, returncode):
        

        self._terminate_process_iou()
        if returncode != 0:
            if returncode == -11:
                message = 'IOU VM "{}" process has stopped with return code: {} (segfault). This could be an issue with the IOU image, using a different image may fix this.\n{}'.format(self.name,
                                                                                                                                                                                         returncode,
                                                                                                                                                                                         self.read_iou_stdout())
            else:
                message = 'IOU VM "{}" process has stopped with return code: {}\n{}'.format(self.name, returncode, self.read_iou_stdout())
            log.warning(message)
            self.project.emit("log.error", {"message": message})
        if self._telnet_server:
            self._telnet_server.close()
            self._telnet_server = None
1030593
def finalize(self, result):
        """"""
        sys.stderr = self._stderr.pop()
        sys.stdout = self._stdout.pop()
        pdb.set_trace = self._set_trace.pop()
        pdb.Pdb.cmdloop = self._cmdloop.pop()
1065475
def _graceful_finish(self):
        """"""

        if not self.process.stdout.closed or not self.process.stderr.closed:
            return # stdout/stderr still open

        if not self.process.stdin.closed:
            self.process.stdin.close()

        if self.number_of_8k_chunks_sent > 0:
            logger.debug('Sent %d * 8k chunks', self.number_of_8k_chunks_sent)

        logger.debug("Finishing up. Process poll: %r", self.process.poll())

        if not self.headers_sent:
            retval = self.process.poll()
            if retval != 0:
                logger.warning("Empty response. Git return value: " + str(retval))
                payload = "Did not produce any data. Errorcode: " + str(retval)
                data = 'HTTP/1.1 500 Internal Server Error\r\nDate: %s\r\nContent-Length: %d\r\n\r\n' % (get_date_header(), len(payload))
                self.headers_sent = True
                data += payload
                self.request.write(data)
            else:
                data = 'HTTP/1.1 200 Ok\r\nDate: %s\r\nContent-Length: 0\r\n\r\n' % get_date_header()
                self.headers_sent = True
                self.request.write(data)

        # if we are in chunked mode, send end chunk with length 0
        elif self.sent_chunks:
            logger.debug("End chunk")
            self.request.write("0\r\n")
            #we could now send some more headers resp. trailers
            self.request.write("\r\n")

        self.request.finish()
804226
def after_return(self, status, retval, task_id, args, kwargs, einfo):
        
        # Only clear the lock after the task's execution if the
        # "unlock_before_run" option is False
        if not self.unlock_before_run():
            key = self.get_key(args, kwargs)
            self.once_backend.clear_lock(key)
454890
def __cleanup_process(self, event):
        
        pid     = event.get_pid()
        process = event.get_process()

        # Cleanup code breakpoints
        for (bp_pid, bp_address) in compat.keys(self.__codeBP):
            if bp_pid == pid:
                bp = self.__codeBP[ (bp_pid, bp_address) ]
                self.__cleanup_breakpoint(event, bp)
                del self.__codeBP[ (bp_pid, bp_address) ]

        # Cleanup page breakpoints
        for (bp_pid, bp_address) in compat.keys(self.__pageBP):
            if bp_pid == pid:
                bp = self.__pageBP[ (bp_pid, bp_address) ]
                self.__cleanup_breakpoint(event, bp)
                del self.__pageBP[ (bp_pid, bp_address) ]

        # Cleanup deferred code breakpoints
        try:
            del self.__deferredBP[pid]
        except KeyError:
            pass
1327911
def check_returncode(self):
        """"""
        if self.returncode:
            raise CalledProcessError(self.returncode, self.args, self.stdout,
                                     self.stderr)
609402
private void checkForCompletion() {
        final String methodName = "checkForCompletion(): ";
        // mark the list complete if that was the last awaited key
        if (actualIndices.isEmpty()) {
            if (tc.isDebugEnabled())
                Tr.debug(tc, methodName + "setting state=COMPLETE");
            state = failedKeys == null
                            ? COMPLETE
                            : COMPLETE_WITH_FAILURES; // state change must be last action
        }
    }
100438
def on_complete(env)
      status_code   = env[:status].to_i
      service_error = Github::Error::ServiceError
      error_class = service_error.error_mapping[status_code]
      if !error_class and (400...600) === status_code
        error_class = service_error
      end
      raise error_class.new(env) if error_class
    end
1232521
def exit_code(self) -> Any:
        
        if self._done() or self.is_killed():
            return self._exit_code
        else:
            raise BehaviourNotFinishedException
438026
def check_complete(task, out_queue):
    
    logger.debug("Checking if %s is complete", task)
    try:
        is_complete = task.complete()
    except Exception:
        is_complete = TracebackWrapper(traceback.format_exc())
    out_queue.put((task, is_complete))
97387
private function finalise()
    {
        // Send output to email
        $this->emailOutput();

        // Call any callback defined
        if (is_callable($this->after)) {
            call_user_func($this->after, $this->output, $this->returnCode);
        }
    }
1182596
def post_process(self, paths, dry_run=False, **options):
        
        with post_process_error_counter(self):
            with patched_name_fn(self, 'hashed_name', 'hashed name'):
                with patched_name_fn(self, 'url', 'url'):
                    for result in super(LaxPostProcessorMixin,
                                        self).post_process(paths, dry_run, **options):
                        yield result
            error_count = self._post_process_error_count
            if error_count:
                print('%s post-processing error%s.' % (error_count,
                        '' if error_count == 1 else 's'))
1072921
def _method_complete(self, result):
    """"""
    if isinstance(result, PrettyTensor):
      self._head = result
      return self
    elif isinstance(result, Loss):
      return result
    elif isinstance(result, PrettyTensorTupleMixin):
      self._head = result[0]
      return result
    else:
      self._head = self._head.with_tensor(result)
      return self