Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Investigate adding gevent support to 0.9 tree #102

gmr opened this Issue · 9 comments

6 participants

@gmr gmr was assigned

I can't help you out with it directly but would like to let you know that there's a ZeroMQ/gevent glue layer at - who knows it, maybe it will serve as a source of inspiration.



Any news on this? Since pika is a pure python implementation. Would gevent.monkey do the job?


No, I've not spent any time with gevent yet and want to get the growing buglist tackled before doing so.


I've tried it with Celery, and on a Gevent reactor, there indeed seem to be concurency issues!

daf commented

We've been running a project on it for nearly a year now, using gevent's normal monkey patching mechanisms. It mostly works ok, but we've built a layer on top of pika that has to go to lengths to make sure you don't do something we've noticed as bad.

We manually patch in some fixes for #97 (my bug) that might be related to gevent.

I've noticed sometimes we get a:

[snip]/eggs/pika-0.9.5-py2.7.egg/pika/ UserWarning: CallbackManager.add: Duplicate callback found for "0:Connection.CloseOk"

Which definetely appears related to the monkey patching - there's a race between channel closing (as called by the connection.close method) and the call at the end of connection.close which checks if there are any channels and if it should call the same method. I think it's mostly harmless but is one of the alarms when using this with gevent.

@steeve Can you elaborate more on your concurrency issues?


I'd have to test it again, but I had some framing errors if I recall correctly

daf commented

Ah, that reminds me. I had to plug a fix in for a similar sounding issue - pika/gevent would sometimes try to ack in the middle of a publish (which is a surprising three AMQP commands) and Rabbit would panic close everything.

Had to use Wireshark to figure out what was happening. Wish Rabbit would at least tell you which channel caused the panic, that would've helped narrow it down.


Another developer and I wrote a gevent adapter for my current employer a while back. For the most part, it has been working flawlessly with no monkey patching. I will be updating it to work with the latest pika version. We've only seen one issue so far and it looks like it might be issue #97.

After I make the update, I'll submit a pull request for adding the adapter to pika.


Closing due to lack of time.

@gmr gmr closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.