#!/usr/bin/python # -*- coding: utf-8 -*- # This program drains all the queues, throwing away all the messages. # Note that messages which are being processed are not and cannot be # drained. import pika import config connection = pika.BlockingConnection(pika.ConnectionParameters( host = config.mq_server)) channel = connection.channel() while True: method, _, _ = channel.basic_get(queue = 'patchq_input', no_ack = True) if not method: break for t in config.tests: qname = "patchq_test_%s" % t while True: method, _, _ = channel.basic_get(queue = qname, no_ack = True) if not method: break while True: method, _, _ = channel.basic_get(queue = 'patchq_reports', no_ack = True) if not method: break print "All queues drained."