[rabbitmq-discuss] Integrating Pika into Tornado

Andrea Corbellini corbellini.andrea at gmail.com
Thu Jul 1 15:10:35 BST 2010

Hello everybody,

Recently I've started to work on a project to make Pika work with the
Tornado web server, and I would like receive some feedback from you
before proposing something for merging. The approach I've used
consists of making Pika more event-based. Since code is better that
words, I've attached what I've done so far (there's also a test
script). As you will see, I haven't touched Pika itself yet, instead
I've written a quick and dirty hack based on the library, rewriting
just the relevant parts.

There are two main steps that needs to be done in order to have
something ready to land into the development mainline. First of all,
the `Connection` and `ChannelHandler` classes should be partially
rewritten in order to make them event-oriented. Then, the asyncore and
the blocking adapters needs to be rewritten in order to make them work
with the new code.

The first step is easy: I've already done most of the work. The only
thing that should be done is to replace the calls to
IOStream.read_bytes() and IOStream.write() with two new functions that
should be overridden by the various adapters. Also, it'd be useful to
add a `callback` argument to methods such as `send_frame`,
`wait_for_open` and so on.

The second step instead requires a bit more work. The things to do
are: make the current adapters more event-based and let them use the
two new functions.

So, basically, the current flow:

connect -> drain_events() -> handle frame

will be changed in order to become:

connect -> [wait for data] -> callback1 -> [wait for data] -> callback2 -> ...

where "[wait for data]" depends on the adapter (e.g.: the Tornado's
adapter will use IOLoop, the blocking adapter will read directly from
the socket).

So, that's my propose. I'd happy to answer any of your questions and
to receive any feedback from you.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: tamqp.tar.gz
Type: application/x-gzip
Size: 7237 bytes
Desc: not available
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20100701/b4e22fe7/attachment.bin>

More information about the rabbitmq-discuss mailing list