[rabbitmq-discuss] Difference between async connection using ioloop and blocking connection for rabbitmq
Gavin M. Roy
gmr at meetme.com
Thu Mar 7 14:55:04 GMT 2013
You should not use time.sleep, in pika, use connection.sleep():
https://pika.readthedocs.org/en/0.9.9/adapters.html#module-pika.adapters.blocking_connection
That will likely change what you're seeing. You're freezing the whole process when you use time.sleep while connection.sleep will block your python app for that time while processing communication with RabbitMQ in the background.
On Thursday, March 7, 2013 at 8:25 AM, Ask Solem wrote:
>
> On Mar 5, 2013, at 11:14 PM, Ameya Patil <Ameya.Patil at servicenow.com (mailto:Ameya.Patil at servicenow.com)> wrote:
>
> > Hi,
> >
> > Ioloops in async connection is exhibiting blocking semantics. I am trying to understand how this is different than a blocking connection
> >
> > The documentation (https://pika.readthedocs.org/en/latest/connecting.html#io-and-event-looping ) states:
> > These IOLoops are blocking methods which loop and listen for events.
> >
> > In a experiment I conducted, I publish 2 messages, each 5 times: message 'test' published by AsyncPublisher and 'test1' by AsyncPublisher1.py.
> >
> > In the consumer I have an if block stating:
> > If body == test:
> > Time.sleep(10)
> >
> > I run AsyncPublisher.py first, and after it has sent 5 test messages I run AsyncPublisher1.py.
> >
> > The output I expect is :
> > Test
> > test1
> > test1
> > test1
> > tes1
> > Test
> > Test
> > Test
> > Test
> >
>
>
> Why do you expect this particular order?
>
> > Instead I get:
> > Test
> > Tes
> > Test
> > Test
> > Test
> > test1
> > test1
> > test1
> > test1
> > test1
> >
> > This is the same as if I would run the sender and receiver using a blocking connection.
> > My question is how does a blocking connection different than ioloop.start ? Does it differ only on multithreading ?
> >
>
>
> It uses Async I/O, not multithreading, so a single process would not run anything in parallel, but it enables you to do multiple I/O operations at the same time by scheduling
> the callbacks for when the operation can be completed. See http://en.wikipedia.org/wiki/Asynchronous_I/O
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com (mailto: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/20130307/12b0ee0d/attachment.htm>
More information about the rabbitmq-discuss
mailing list