[rabbitmq-discuss] Adapter merges tornado and pika

Richard Clark richard at redspider.co.nz
Sat Mar 20 14:06:45 GMT 2010

Ok, I'm half asleep so I'll make this quick. After fighting with
numerous strategies for melding tornado and rabbitmq in a way that
doesn't involve spawning extra processes, mangling my interpreter,
going anywhere near twisted, mangling my ability to dispatch properly
off multiple queues on a single channel etc, I finally managed
something that, at least for first appearances, works.

The changes are fairly simple. Tornado needs one 2 line change to
ioloop to allow it to run a loop once, rather than spinning - sadly
attempts to do it without this change caused nightmarish bugs to

In addition to that, two files (attached, no warranty etc etc) are

asyncloop.py, an ioloop handler that mostly pretends to be an asyncore
ioloop_adapter.py, an adapter almost exactly like the
asyncore_adapter.py in pika, except it uses the asyncloop and gets rid
of some crap (and, unfortunately, timers, but they're easy to put back
using ioloop stuff)

In no way is this production code, it's barely even tested. I intend
to try and get it further in that direction tomorrow, but in case
anyone else has been banging their head on the same problem I figured
I'd throw the strategy out there.


http://gist.github.com/338683 (requires an amqp echo service on echo/

cross-posting to tornado as well.

More information about the rabbitmq-discuss mailing list