@stats.Counted("grr_frontendserver_handle_num")
  @stats.Timed("grr_frontendserver_handle_time")
  def HandleMessageBundles(self, request_comms, response_comms):
    """Processes a queue of messages as passed from the client.

    We basically dispatch all the GrrMessages in the queue to the task scheduler
    for backend processing. We then retrieve from the TS the messages destined
    for this client.

    Args:
       request_comms: A ClientCommunication rdfvalue with messages sent by the
       client. source should be set to the client CN.

       response_comms: A ClientCommunication rdfvalue of jobs destined to this
       client.

    Returns:
       tuple of (source, message_count) where message_count is the number of
       messages received from the client with common name source.
    """
    messages, source, timestamp = self._communicator.DecodeMessages(
        request_comms)

    now = time.time()
    if messages:
      # Receive messages in line.
      self.ReceiveMessages(source, messages)

    # We send the client a maximum of self.max_queue_size messages
    required_count = max(0, request_comms.queue_size - self.max_queue_size)
    tasks = []

    message_list = rdf_flows.MessageList()
    if self.UpdateAndCheckIfShouldThrottle(time.time()):
      stats.STATS.IncrementCounter("grr_frontendserver_handle_throttled_num")

    elif self.throttle_callback():
      # Only give the client messages if we are able to receive them in a
      # reasonable time.
      if time.time() - now < 10:
        tasks = self.DrainTaskSchedulerQueueForClient(source, required_count,
                                                      message_list)
    else:
      stats.STATS.IncrementCounter("grr_frontendserver_handle_throttled_num")

    # Encode the message_list in the response_comms using the same API version
    # the client used.
    try:
      self._communicator.EncodeMessages(
          message_list, response_comms, destination=str(source),
          timestamp=timestamp, api_version=request_comms.api_version)
    except communicator.UnknownClientCert:
      # We can not encode messages to the client yet because we do not have the
      # client certificate - return them to the queue so we can try again later.
      queue_manager.QueueManager(token=self.token).Schedule(tasks)
      raise

    return source, len(messages)
dataset/ETHPy150Open google/grr/grr/lib/flow.py/FrontEndServer.HandleMessageBundles/swapped operands of `-`