<div>
You should not use time.sleep, in pika, use connection.sleep():</div><div><br></div><div><a href="https://pika.readthedocs.org/en/0.9.9/adapters.html#module-pika.adapters.blocking_connection">https://pika.readthedocs.org/en/0.9.9/adapters.html#module-pika.adapters.blocking_connection</a></div><div><br></div><div>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.</div>
<div></div>
<p style="color: #A0A0A8;">On Thursday, March 7, 2013 at 8:25 AM, Ask Solem wrote:</p>
<blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;">
<span><div><div><div><br></div><div>On Mar 5, 2013, at 11:14 PM, Ameya Patil <<a href="mailto:Ameya.Patil@servicenow.com">Ameya.Patil@servicenow.com</a>> wrote:</div><div><br></div><blockquote type="cite"><div><div>Hi, </div><div><br></div><div>Ioloops in async connection is exhibiting blocking semantics. I am trying to understand how this is different than a blocking connection</div><div><br></div><div>The documentation (<a href="https://pika.readthedocs.org/en/latest/connecting.html#io-and-event-looping">https://pika.readthedocs.org/en/latest/connecting.html#io-and-event-looping</a> ) states:</div><div>These IOLoops are blocking methods which loop and listen for events.</div><div><br></div><div>In a experiment I conducted, I publish 2 messages, each 5 times: message 'test' published by AsyncPublisher and 'test1' by AsyncPublisher1.py. </div><div><br></div><div>In the consumer I have an if block stating:</div><div>If body == test: </div><div> Time.sleep(10)</div><div><br></div><div>I run AsyncPublisher.py first, and after it has sent 5 test messages I run AsyncPublisher1.py.</div><div><br></div><div>The output I expect is :</div><div>Test</div><div>test1</div><div>test1</div><div>test1</div><div>tes1</div><div>Test</div><div>Test</div><div>Test</div><div>Test</div></div></blockquote><div><br></div><div>Why do you expect this particular order?</div><div><br></div><blockquote type="cite"><div><div>Instead I get:</div><div>Test</div><div>Tes</div><div>Test</div><div>Test</div><div>Test</div><div>test1</div><div>test1</div><div>test1</div><div>test1</div><div>test1</div><div><br></div><div>This is the same as if I would run the sender and receiver using a blocking connection.</div><div>My question is how does a blocking connection different than ioloop.start ? Does it differ only on multithreading ? </div></div></blockquote><div><br></div><div>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</div><div>the callbacks for when the operation can be completed. See <a href="http://en.wikipedia.org/wiki/Asynchronous_I/O">http://en.wikipedia.org/wiki/Asynchronous_I/O</a></div><div>_______________________________________________</div><div>rabbitmq-discuss mailing list</div><div><a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a></div><div><a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a></div></div></div></span>
</blockquote>
<div>
<br>
</div>