[rabbitmq-discuss] Pika problem, channel starts consuming before I call start_consuming(), then raises Queue.DeclareOk KeyError

Aaron Voelker aaron at contextlogic.com
Thu Sep 22 00:31:55 BST 2011


Update: I have opened an issue with Pika on Github: https://github.com/pika/pika/issues/86

Wasn't able to find where to post issues before (wasn't listed on
http://tonyg.github.com/pika/). Sorry for the cross-post.

Aaron

On Sep 21, 2:26 pm, Aaron Voelker <aa... at contextlogic.com> wrote:
> Environment: Python 2.6.6, Ubuntu 10.10, Pika 0.95. I have reproduced
> this problem on several machines with the same specs.
>
> Description of Test: Publish to test1, then consume from test1 and
> test2.
>
> What Happens: The queue with the message begins consuming before I
> have even told it to start_consuming. Pika seems to get into a weird
> state, and then throws a Queue.DeclareOk KeyError.
>
> """
> In Callback Hello World
> Traceback (most recent call last):
>   File "./rabbittests.py", line 31, in <module>
>     channel.queue_declare(queue=queue_name)
>   File "/usr/local/lib/python2.6/dist-packages/pika/spec.py", line
> 2437, in queue_declare
>     [Queue.DeclareOk])
>   File "/usr/local/lib/python2.6/dist-packages/pika/adapters/
> blocking_connection.py", line 221, in rpc
>     frame = self._frames[reply]
> KeyError: 'Queue.DeclareOk'
> """
>
> The Code:
>
> #!/usr/bin/python
>
> import pika
>
> ######### Producer Code
>
> connection =
> pika.BlockingConnection(pika.ConnectionParameters('localhost'))
> channel = connection.channel()
>
> for queue_name in ('test1', 'test2'):
>     channel.queue_declare(queue=queue_name)
>
> channel.basic_publish(exchange='', routing_key='test1', body='Hello
> World')
> connection.close()
>
> ######### Consumer Code
>
> connection =
> pika.BlockingConnection(pika.ConnectionParameters('localhost'))
> channel = connection.channel()
>
> def callback(ch, method, properties, body):
>     print "In Callback", body
>     ch.basic_ack(delivery_tag = method.delivery_tag)
>
> for queue_name in ('test1', 'test2'):
>     channel.queue_declare(queue=queue_name)
>     channel.basic_consume(callback, queue=queue_name)
>
> assert False # NOTE: this doesn't execute!
> channel.start_consuming()
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-disc... at lists.rabbitmq.comhttps://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss


More information about the rabbitmq-discuss mailing list