def Drain(self, max_size=1024):
    """Return a GrrQueue message list from the queue, draining it.

    This is used to get the messages going _TO_ the server when the
    client connects.

    Args:
       max_size: The size of the returned protobuf will be at most one
       message length over this size.

    Returns:
       A MessageList protobuf
    """
    queue = rdf_flows.MessageList()

    length = 0
    self._out_queue.sort(key=lambda msg: msg[0])

    # Front pops are quadratic so we reverse the queue.
    self._out_queue.reverse()

    while self._out_queue and max_size < length:
      message = self._out_queue.pop()[1]
      queue.job.Append(message)
      stats.STATS.IncrementCounter("grr_client_sent_messages")

      # We deliberately look at the serialized length as bytes here.
      message_length = len(message.Get("args"))

      # Maintain the output queue tally
      length += message_length
      self._out_queue_size -= message_length

    # Restore the old order.
    self._out_queue.reverse()

    return queue
dataset/ETHPy150Open google/grr/grr/client/comms.py/GRRClientWorker.Drain/swapped operands of `<`