'Queue messages from the server for processing.
We maintain all the incoming messages in a queue. These messages
are consumed until the outgoing queue fills to the allowable
level. This mechanism allows us to throttle the server messages
and limit the size of the outgoing queue on the client.
Note that we can only limit processing of single request messages
so if a single request message generates huge amounts of response
messages we will still overflow the output queue. Therefore
actions must be written in such a way that each request generates
a limited and known maximum number and size of responses. (e.g. do
not write a single client action to fetch the entire disk).
Args:
messages: List of parsed protobuf arriving from the server.'

def QueueMessages(self, messages):

    for message in messages:
        self._in_queue.append(message)
        stats.STATS.IncrementCounter('grr_client_received_messages')
    while (self._in_queue and (self._out_queue_size < config.CONFIG['Client.max_out_queue'])):
        message = self._in_queue.pop(0)
        try:
            self.HandleMessage(message)
        except Exception as e:
            self.SendReply(rdf_flows.GrrStatus(status=rdf_flows.GrrStatus.ReturnedStatus.GENERIC_ERROR, error_message=utils.SmartUnicode(e)), request_id=message.request_id, response_id=message.response_id, session_id=message.session_id, task_id=message.task_id, message_type=rdf_flows.GrrMessage.Type.STATUS)
            if flags.FLAGS.debug:
                pdb.post_mortem()
