[rabbitmq-discuss] Pika disconnects

John Reuning john at ibiblio.org
Fri Oct 7 13:49:51 BST 2011


I have a multi-threaded python application using pika to publish
messages to rabbitmq (all centos 6).  It works most of the time,
except for intermittent disconnects and bad file descriptor socket
errors.  The disconnects manifest as the ioloop exiting.  I registered
a custom on_connection_close callback function, as well as a custom
reconnection strategy object.  Neither is triggered when a disconnect
occurs and the ioloop exists.  The socket EBADF exceptions come from
calling basic_publish on a channel object after the rabbitmq
connection has terminated.

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?

Thanks,

-John


More information about the rabbitmq-discuss mailing list