Files
zulip/zerver/management/commands/purge_queue.py
Zev Benjamin 8aa2c7b547 Make the purge_queue management command more efficient
Before we were removing items individually from the queue.  We now
directly use RabbitMQ's queue purging mechanism.

(imported from commit 62ab52c724c5a221b4c81a967154a4046a579f84)
2013-10-28 14:30:53 -04:00

20 lines
626 B
Python

from __future__ import absolute_import
from django.core.management.base import BaseCommand
from django.core.management import CommandError
from zerver.lib.queue import SimpleQueueClient
import logging
class Command(BaseCommand):
args = "<queue name>"
help = "Discards all messages from the given queue"
def handle(self, *args, **options):
if len(args) != 1:
raise CommandError("Wrong number of arguments")
queue_name = args[0]
queue = SimpleQueueClient()
queue.ensure_queue(queue_name, lambda: None)
queue.channel.queue_purge(queue_name)
print "Done"