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

145 views
Skip to first unread message

Aaron Voelker

unread,
Sep 21, 2011, 5:26:59 PM9/21/11
to rabbitmq...@lists.rabbitmq.com
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...@lists.rabbitmq.com
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss

Aaron Voelker

unread,
Sep 21, 2011, 7:31:55 PM9/21/11
to rabbitmq...@lists.rabbitmq.com
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

> rabbitmq-disc...@lists.rabbitmq.comhttps://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss

Tony Garnock-Jones

unread,
Sep 21, 2011, 7:38:42 PM9/21/11
to Aaron Voelker, rabbitmq...@lists.rabbitmq.com
On 21 September 2011 19:31, Aaron Voelker <aa...@contextlogic.com> wrote:
Wasn't able to find where to post issues before (wasn't listed on
http://tonyg.github.com/pika/). Sorry for the cross-post.

Hmm! Those pages shouldn't be there anymore. http://pika.github.com/ is the new URL. Your point still stands about there not being any pointers to the GH issue tracker, of course :-)

Regards,
  Tony

Aaron Voelker

unread,
Sep 29, 2011, 3:23:30 PM9/29/11
to rabbitmq...@lists.rabbitmq.com
For those interested, replacing my BlockingConnection with a
TornadoConnection solved this problem. I have been using this as a
workaround for a couple days and haven't had any more issues.

On Sep 21, 4:38 pm, Tony Garnock-Jones <tonygarnockjones


+rabbi...@gmail.com> wrote:
> On 21 September 2011 19:31, Aaron Voelker <aa...@contextlogic.com> wrote:
>
> > Wasn't able to find where to post issues before (wasn't listed on
> >http://tonyg.github.com/pika/). Sorry for the cross-post.
>

> Hmm! Those pages shouldn't be there anymore.http://pika.github.com/is the


> new URL. Your point still stands about there not being any pointers to the
> GH issue tracker, of course :-)
>
> Regards,
>   Tony
>

Reply all
Reply to author
Forward
0 new messages