[rabbitmq-discuss] Pika blocking receive does not block

Jim Irrer irrer at umich.edu
Fri Jul 22 21:15:51 BST 2011


Excellent!  Problem solved.

Many thanks,

- Jim

Jim Irrer     irrer at umich.edu       (734) 647-4409
University of Michigan Hospital Radiation Oncology
519 W. William St.             Ann Arbor, MI 48103


2011/7/22 Raphaël De GIUSTI <raphael.degiusti at guardis.com>

> Hello,
>
> You should try the start_consuming() method. See the example on github :
> https://github.com/pika/pika/blob/master/examples/blocking/demo_receive.py
>
> Raph
>
> On Fri, Jul 22, 2011 at 8:12 PM, Jim Irrer <irrer at umich.edu> wrote:
>
>> Hi -
>>
>> I'm trying to implement a blocking client that does an RPC style call to a
>> server and get a result.  Currently my client sends a message that the
>> server
>> receives, and then the client immediately checks for a response using
>> basic_consume.  The basic_consume method is executed before the
>> server can respond, and returns without getting a result.
>>
>> If I add a 'sleep' before the basic_consume, everything works fine, but
>> that is a poor solution.  I want to block until there is something on the
>> queue to read.
>>
>> outline of the code:
>>
>> use channel.queue_declare to declare the reply queue
>>
>> use queue_bind to bind the reply queue to a unique string
>>
>> call basic_consume to set up the reply queue handler (I thought that this
>> would block but it does not)
>>
>> use basic_publish to send a message to the server, with the reply_to
>> property set to the unique string
>>
>> sleep long enough for server to process message (do not want to do this,
>> but if I don't then I get no reply)
>>
>> call basic_get (not sure why, but it makes things work)
>>
>>
>> I have some holes in my understanding, but to not know how to make the
>> program wait until there is something on the queue and then read it.
>>
>> Thanks for any hints,
>>
>> - Jim
>>
>> Jim Irrer     irrer at umich.edu       (734) 647-4409
>> University of Michigan Hospital Radiation Oncology
>> 519 W. William St.             Ann Arbor, MI 48103
>>
>> _______________________________________________
>> rabbitmq-discuss mailing list
>> rabbitmq-discuss at lists.rabbitmq.com
>> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20110722/6fe4fac6/attachment.htm>


More information about the rabbitmq-discuss mailing list