Posts

Showing posts with the label django-celery

Celery issue

(Thank for http://permalink.gmane.org/gmane.comp.python.amqp.celery.user/1695) To create a queue? You know celery automatically declares queues right? You wouldn't 'create' a queue per se, you only declare them, in some context the queue is only actually created when a message is delivered to it. For some transports queues and exchanges *must* be declared by every process that uses them. If you use RabbitMQ then you can create a queue manually like this: from celery import current_app as celery from kombu import Queue, Exchange q = Queue("foo", Exchange("foo", type="direct"), routing_key="foo") with celery.broker_connection() as conn: with conn.channel() as channel: q(channel).declare()

Purge queues with amqplib

Use amqplib from amqplib import client_0_8 as amqp # Create connection conn = amqp.Connection(     host="localhost:5672",     userid="xxxxx",     password="xxxxxxxxx"     virtual_host="/",     insist=False ) chan = conn.channel() # Get list of queues (list type) # # ex. list_queues = ['queue-1','queue2',....] # for queue in list_queues:     chan.queue_purge(queue) Preparation Data ( thk juacompe )         sudo rabbitmqctl list_queues name > queues.py    inside vim let's do        $s/^/"/  # for insert " infront of queue name       $s/$/",/ # for insert ", infront of queue name       fill queue=["xxxx for the first line       then you will get something like this       ----------------------------       queues_list = ["xxxxx",       "xxxxx", ...