[rabbitmq-discuss] Pika disconnects
Marek Majkowski
majek04 at gmail.com
Sat Oct 8 11:03:28 BST 2011
On Fri, Oct 7, 2011 at 13:49, John Reuning <john at ibiblio.org> wrote:
> I read that pika isn't thread safe, so I've tried adding a
> threading.RLock around the basic_publish call. This reduces the
> frequency of the disconnects but doesn't eliminate them. I could wrap
> the pika functionality in another layer, check for a disconnect, and
> recycle everything. However, it would be nice to know why this
> happens. Anyone have suggestions?
John,
Pika doesn't support multi threading. Wrapping single basic_publish
isn't good enough - the side effect of this command (network buffer)
is going to affect different thread (the thread with event loop).
I'm afraid there isn't a simple workaround. You can try to wrap
everything (including event loop) in a lock - and thus allow only
one thread at a time to use connection/network socket/buffers.
But doing that will be rather hard (how to stop event loop
if other thread wants to publish?)
Or, maybe a better solution would be to use multiple connections,
one connection per thread.
Does it sound reasonable?
Cheers,
Marek
More information about the rabbitmq-discuss
mailing list