From e8ccee7948cc692481bf7625622c73968d5b2395 Mon Sep 17 00:00:00 2001 From: Dana Powers Date: Fri, 23 Mar 2018 05:56:11 -0700 Subject: [PATCH] Check for immediate failure when looking up coordinator in heartbeat thread (#1457) --- kafka/coordinator/base.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kafka/coordinator/base.py b/kafka/coordinator/base.py index bff628669..9f67d6b6d 100644 --- a/kafka/coordinator/base.py +++ b/kafka/coordinator/base.py @@ -945,7 +945,11 @@ def _run_once(self): self.coordinator._client.poll(timeout_ms=0) if self.coordinator.coordinator_unknown(): - if not self.coordinator.lookup_coordinator().is_done: + future = self.coordinator.lookup_coordinator() + if not future.is_done or future.failed(): + # the immediate future check ensures that we backoff + # properly in the case that no brokers are available + # to connect to (and the future is automatically failed). self.coordinator._lock.wait(self.coordinator.config['retry_backoff_ms'] / 1000) elif self.coordinator.heartbeat.session_timeout_expired():