Skip to content

Commit

Permalink
Attempt to fix the clear-queue method
Browse files Browse the repository at this point in the history
  • Loading branch information
andylolz committed Jan 14, 2016
1 parent 6a98f1c commit 6f54f5c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
14 changes: 3 additions & 11 deletions bin/dqtool
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,10 @@ def make_csv_output(options):
s = iatidq.dqcsv.make_csv(organisations, True, True)
print s.read()

def clear_queue(options):
def clear_queues(options):
from iatidq import queue
def run_queue(queue_name):
while True:
queue.handle_queue(queue_name, callback_fn)

def callback_fn(ch, method, properties, body):
print "Dequeuing"
ch.basic_ack(delivery_tag=method.delivery_tag)

the_queue='iati_download_queue'
[ run_queue(queue_name) for queue_name in
[ queue.delete_queue(queue_name) for queue_name in
['iati_download_queue', 'iati_tests_queue'] ]

def test_package(options):
Expand Down Expand Up @@ -396,7 +388,7 @@ modes = {
"list-modes": list_modes,
"make-survey-data": make_survey_data,
"make-csv-output": make_csv_output,
"clear-queue": clear_queue,
"clear-queues": clear_queues,
"associate-test": associate_test,
"test-package": test_package,
"check-package-results": check_package_results,
Expand Down
11 changes: 11 additions & 0 deletions iatidq/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ def handle_queue_generator(queue_name):
channel.close()
connection.close()

def delete_queue(queue_name):
try:
connection = get_connection('localhost')
channel = connection.channel()
channel.queue_delete(queue=queue_name)
except:
pass
finally:
channel.close()
connection.close()

def exhaust_queue(queue, callback_fn):
try:
connection = pika.BlockingConnection(
Expand Down

0 comments on commit 6f54f5c

Please sign in to comment.