Skip to content

Instantly share code, notes, and snippets.

@scisco
Created May 11, 2016 19:19
Show Gist options
  • Save scisco/ec359da9544798fd7e19ce2d2aaa7099 to your computer and use it in GitHub Desktop.
Save scisco/ec359da9544798fd7e19ce2d2aaa7099 to your computer and use it in GitHub Desktop.

Revisions

  1. Scisco created this gist May 11, 2016.
    22 changes: 22 additions & 0 deletions cleanup.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    import json
    import pika

    url = 'amqp://url/'
    connection = pika.BlockingConnection(pika.URLParameters(url))
    channel = connection.channel()

    while True:
    method_frame, header_frame, body = channel.basic_get('default')
    if method_frame:
    if method_frame.message_count < 1000:
    break
    else:
    print(method_frame.message_count)
    body = json.loads(body.decode('utf8'))
    if body['task'] == 'plans.tasks.calculate_task_totals' or body['task'] == 'plans.tasks.calculate_aoi_totals':
    print('discarded')
    channel.basic_ack(method_frame.delivery_tag)
    else:
    print(body)
    else:
    break