diff --git a/pulsar/client/amqp_exchange.py b/pulsar/client/amqp_exchange.py index 55e9a05523c8a7d1a14b63a43b96ae6142c81e31..792a08927f7990f5861c846e62d3cc61549485c9 100644 --- a/pulsar/client/amqp_exchange.py +++ b/pulsar/client/amqp_exchange.py @@ -86,9 +86,15 @@ class PulsarExchange(object): except (IOError, socket.error), exc: # In testing, errno is None log.warning('Got %s, will retry: %s', exc.__class__.__name__, exc) - if heartbeat_thread: - heartbeat_thread.join() - sleep(DEFAULT_RECONNECT_CONSUMER_WAIT) + try: + if heartbeat_thread: + heartbeat_thread.join(DEFAULT_HEARTBEAT_JOIN_TIMEOUT) + except Exception: + log.exception("Failed to join heartbeat thread, this is bad?") + try: + sleep(DEFAULT_RECONNECT_CONSUMER_WAIT) + except Exception: + log.exception("Interrupted sleep while waiting to reconnect to message queue, may restart unless problems encountered.") except BaseException: log.exception("Problem consuming queue, consumer quitting in problematic fashion!") raise