On Monday, August 6, 2012 10:29:00 AM UTC-4, RaphaĆ«l De Giusti wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">Hi everyone,<div><br></div><div>I'm interested in running pika's IOLoop in a thread and I came across this code sample :&nbsp;<a href="http://cms02.phys.ntu.edu.tw/tracs/env/browser/trunk/messaging/pika/mon.py" target="_blank">http://cms02.phys.ntu.edu.<wbr>tw/tracs/env/browser/trunk/<wbr>messaging/pika/mon.py</a></div><div><br></div><div>I was wondering why and what could be the advantages of wrapping the callbacks in methods (I can understand the&nbsp;on_exchange_declared() method that returns a different callback according to thread's name) ?</div></blockquote><div><br></div><div>&nbsp;Advantages would be allowing the class to have direct access to the connection object, and being able to add custom functionality to the callbacks as needed - for example, passing custom headers when declaring exchanges and queues (if you want to use some of the other awesome RabbitMQ features like high availability, ttl, dead letter exchanges)</div><div>&nbsp;</div><blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div></div><div>Another question is why considering multiprocessing over threading in this case ?</div></blockquote><div><br></div>Multiprocessing is a way of getting around the GIL, which can make your application actually act in parallel. Threaded python cannot actually execute concurrent threads.&nbsp;