'Returns all messages in the desired queue'

def drain_queue(self, queue_name, json=False):

    messages = []
    def opened():
        while True:
            (meta, _, message) = self.channel.basic_get(queue_name)
            if (not message):
                break
            self.channel.basic_ack(meta.delivery_tag)
            if json:
                message = ujson.loads(message)
            messages.append(message)
    self.ensure_queue(queue_name, opened)
    return messages
