Does the actual processing of the completed requests.
322261
def _ProcessCompletedRequests(self, notification):
    """"""
    # First ensure that client messages are all removed. NOTE: We make a new
    # queue manager here because we want only the client messages to be removed
    # ASAP. This must happen before we actually run the flow to ensure the
    # client requests are removed from the client queues.
    with queue_manager.QueueManager(token=self.token) as manager:
      for request, _ in manager.FetchCompletedRequests(
          self.session_id, timestamp=(0, notification.timestamp)):
        # Requests which are not destined to clients have no embedded request
        # message.
        if request.HasField("request"):
          manager.DeQueueClientRequest(request.request)

    # The flow is dead - remove all outstanding requests and responses.
    if not self.IsRunning():
      self.queue_manager.DestroyFlowStates(self.session_id)
      return

    processing = []
    while True:
      try:
        # Here we only care about completed requests - i.e. those requests with
        # responses followed by a status message.
        for request, responses in self.queue_manager.FetchCompletedResponses(
            self.session_id, timestamp=(0, notification.timestamp)):

          if request.id == 0:
            continue

          if not responses:
            break

          # We are missing a needed request - maybe its not completed yet.
          if request.id > self.context.next_processed_request:
            stats_collector_instance.Get().IncrementCounter(
                "grr_response_out_of_order")
            break

          # Not the request we are looking for - we have seen it before
          # already.
          if request.id < self.context.next_processed_request:
            self.queue_manager.DeleteRequest(request)
            continue

          if not responses:
            continue

          # Do we have all the responses here? This can happen if some of the
          # responses were lost.
          if len(responses) != responses[-1].response_id:
            # If we can retransmit do so. Note, this is different from the
            # automatic retransmission facilitated by the task scheduler (the
            # Task.task_ttl field) which would happen regardless of these.
            if request.transmission_count < 5:
              stats_collector_instance.Get().IncrementCounter(
                  "grr_request_retransmission_count")
              request.transmission_count += 1
              self.ReQueueRequest(request)
            break

          # If we get here its all good - run the flow.
          if self.IsRunning():
            self.flow_obj.HeartBeat()
            self.RunStateMethod(request.next_state, request, responses)

          # Quit early if we are no longer alive.
          else:
            break

          # At this point we have processed this request - we can remove it and
          # its responses from the queue.
          self.queue_manager.DeleteRequest(request)
          self.context.next_processed_request += 1
          self.DecrementOutstandingRequests()

        # Are there any more outstanding requests?
        if not self.OutstandingRequests():
          # Allow the flow to cleanup
          if self.IsRunning() and self.context.current_state != "End":
            self.RunStateMethod("End")

        # Rechecking the OutstandingRequests allows the End state (which was
        # called above) to issue further client requests - hence postpone
        # termination.
        if not self.OutstandingRequests():
          # TODO(user): Deprecate in favor of 'flow_completions' metric.
          stats_collector_instance.Get().IncrementCounter(
              "grr_flow_completed_count")

          stats_collector_instance.Get().IncrementCounter(
              "flow_completions", fields=[self.flow_obj.Name()])
          logging.debug(
              "Destroying session %s(%s) for client %s", self.session_id,
              self.flow_obj.Name(), self.runner_args.client_id)

          self.flow_obj.Terminate()

        # We are done here.
        return

      except queue_manager.MoreDataException:
        # Join any threads.
        for event in processing:
          event.wait()

        # We did not read all the requests/responses in this run in order to
        # keep a low memory footprint and have to make another pass.
        self.FlushMessages()
        self.flow_obj.Flush()
        continue

      finally:
        # Join any threads.
        for event in processing:
          event.wait()
105513
public void complete() {
        Session session = getSession(false);
        if (session == null) {
            return;
        }
        sessionHandler.complete(session);
    }
152146
public function doProcess()
	{

		// double request errors
		$this->checkDouble();

		// process type errors
		$rc = $this->doProcessType();
		if ($rc !== '00') {
			$this->payment->status = Status::ERROR;
			$this->payment->save();

			return;
		}

		$this->payment->saveByType();

	}
605738
private void completeResponses() {
    // Iterate through queued responses and complete as many as possible.
    ResponseCallback response = responseCallbacks.get(responseSequence + 1);
    while (response != null) {
      // If the response was completed, remove the response callback from the response queue,
      // increment the response sequence number, and check the next response.
      if (completeResponse(response.response, response.callback)) {
        responseCallbacks.remove(++responseSequence);
        response = responseCallbacks.get(responseSequence + 1);
      } else {
        break;
      }
    }

    // Once we've completed as many responses as possible, if no more operations are outstanding
    // and events remain in the event queue, complete the events.
    if (requestSequence == responseSequence) {
      EventCallback eventCallback = eventCallbacks.poll();
      while (eventCallback != null) {
        log.trace("Completing {}", eventCallback.request);
        eventCallback.run();
        eventIndex = eventCallback.request.eventIndex();
        eventCallback = eventCallbacks.poll();
      }
    }
  }
293803
def done(self):
        """"""
        if self._finished or self._unfinished:
            return False
        # Clear the 'current' values when iteration is done.
        self.current_index = self.current_future = None
        return True
31809
function done( error ) {
		if ( error && !err ) {
			err = error;
		}
		if ( count === total ) {
			debug( 'Request completed.' );
			if ( err ) {
				if ( ratelimit ) {
					return clbk( err, null, ratelimit );
				}
				return clbk( err );
			}
			if ( total > 1 ) {
				debug( 'Flattening paginated results.' );
				data = flatten( data );
				debug( 'Total number of results: %d', data.length );
			}
			return clbk( null, data, ratelimit );
		}
	}
957307
public void complete() {
        this.endDate = new Date();
        
        if (reports.stream().allMatch(report -> report.isSuccessful() == true)) {
            this.successful = true;
        }
    }
1032261
public function process()
    {
        // Run the UpdatePackageInfo task
        $updateTask = Injector::inst()->create(UpdatePackageInfoTask::class);
        $updateTask->run(null);

        // mark job as completed
        $this->isComplete = true;
    }
1071607
public function process()
    {
        // Skip blank queues
        if (empty($this->batches)) {
            return true;
        }

        // Don't re-process completed queue
        if ($this->currentBatch >= count($this->batches)) {
            return true;
        }

        // Send current patch to indexes
        $this->prepareIndexes();

        // Advance to next batch if successful
        $this->setBatch($this->currentBatch + 1);
        return true;
    }
898472
private void process()
    {
        if (requestUri.length() > 1) {
            parts = new ArrayList<String>(10);
            for ( int i = 1; i < requestUri.length(); ) {
                int sIdx = i;
                int eIdx = requestUri.indexOf('/', sIdx + 1);
                
                //not matched or reach the end
                if ( eIdx == -1 ) {
                    parts.add(requestUri.substring(sIdx));
                    break;
                } 
                
                parts.add(requestUri.substring(sIdx, eIdx));
                i = eIdx + 1;
            }
            
            /*
             * check and add a empty method name
             * with request style like /tokenizer/
            */
            if ( requestUri.charAt(requestUri.length()-1) == '/' ) {
                parts.add("");
            }
            
            int length = parts.size();
            if ( length > 1 ) {
                IStringBuffer sb = new IStringBuffer();
                for ( int i = 0; i < length - 1; i++ ) {
                    int l = sb.length();
                    sb.append(parts.get(i));
                    
                    //make sure the first letter is uppercase
                    char chr = sb.charAt(l);
                    if ( chr >= 90 ) {
                        chr -= 32;
                        sb.set(l, chr);
                    }
                }
                
                controller = sb.toString();
            }
            
            method = parts.get(length-1);
        }
    }
187110
public function process ()
		{
			if (!empty( $this->_params ))
			{
				if ($this->getIsUploading())
					$this->uploadChunk();
				else
					$this->testChunk();
			}
		}
982292
protected function requestFinished()
    {
        $this->onResponse->executeOne($this, true);
        $this->state = self::STATE_ROOT;
        $this->contentLength = -1;
        $this->curChunkSize = null;
        $this->chunked = false;
        $this->eofTerminated = false;
        $this->headers = [];
        $this->rawHeaders = null;
        $this->contentType = null;
        $this->charset = null;
        $this->body = '';
        $this->responseCode = 0;
        $this->reqType = null;
        if (!$this->keepalive) {
            $this->finish();
        }
        $this->checkFree();
    }
94196
function (done) {
      if (called) return;

      called = true;

      // wait for req events to fire
      process.nextTick(function() {
        if (waitend && req.readable) {
          // dump rest of request
          req.resume();
          req.once('end', done);
          return;
        }

        done();
      });
    }
1375033
public function complete()
    {
        $this->stopped();

        $this->setStatus(Job::STATUS_COMPLETE);

        $this->redis->zadd(Queue::redisKey($this->queue, 'processed'), time(), $this->payload);
        Stats::incr('processed', 1);
        Stats::incr('processed', 1, Queue::redisKey($this->queue, 'stats'));

        Event::fire(Event::JOB_COMPLETE, $this);
    }
800714
def finish(self):
        
        assert self._request, "Request closed"
        self._request_finished = True
        if self.m2req.should_close() or self.no_keep_alive:
            self._send("")
        self._request = None
1318897
private void finishStatus(MtasSolrStatus status) {
		if (!status.finished()) {
			status.setFinished();
			if (requestHandler != null) {
				try {
					requestHandler.finishStatus(status);
				} catch (IOException e) {
					log.error(e);
				}
			}
		}
	}
483953
public function completeResponse()
    {
        if (!isset($this->response)) {
            $this->response = array();
        }

        if (is_callable($this->responseCodeHandler)) {
            $responseCodeHandler = $this->responseCodeHandler;
            $responseStatus = $responseCodeHandler();
            if ($responseStatus) {
                $this->response['status'] = $responseStatus;
            }
        }
    }