drain_events() stuck even when timeout specified

Skip to first unread message

Alex Lyakas

Apr 9, 2012, 2:06:26 PM4/9/12
to carrot-users
Greetings everybody,

I am using python-combu 1.0.4-2 shipped with ubuntu-natty.

I have a code that creates a BrokerConnection to the server and calls
connection.drain_events(timeout=5). As excepted, socket.timeout
exception is thrown after 5 seconds of inactivity. However, if I do
"ifconfig down eth<X>" on the relevant interface, then drain_events()
gets stuck and does not return, even after a 5-sec timeout. At this
point, the TCP connection in "netstat" still appears as ESTABLISHED.

What I would like to accomplish, is to call ensure_connection() after
drain_events() throws sock.timeout. But it looks like if the interface
is down, ensure_connection() still returns success (if I don't call

On the server machine, I see that the rabbitmq server closes the TCP
connection after a period of inactivity of around 15 minutes (possibly
due to auto_delete=True in Queue parameters). After that happens, even
if I bring up the interface on the client machine, connection doesn't
work, because:
# On the server side, there is no TCP connection
# On the client side, drain_events() doesn't return and doesn't throw
So there is no trigger for the client to reconnect.

How can I make the code to reconnect after "ifconfig up"?

Reply all
Reply to author
0 new messages