summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDana Powers <dana.powers@gmail.com>2019-08-16 11:04:10 -0700
committerJeff Widman <jeff@jeffwidman.com>2019-08-16 11:04:10 -0700
commit5bc25292b8bb5b20ba2fff481fdc77b9909d0831 (patch)
tree6d3808298d0a9099fda2028f8d777541428e9255
parentace6af5e5d2ff7b900bc694065562127b4efe8dc (diff)
downloadkafka-python-5bc25292b8bb5b20ba2fff481fdc77b9909d0831.tar.gz
Reduce internal client poll timeout for consumer iterator interface (#1824)
More attempts to address heartbeat timing issues in consumers, especially with the iterator interface. Here we can reduce the `client.poll` timeout to at most the retry backoff (typically 100ms) so that the consumer iterator interface doesn't block for longer than the heartbeat timeout.
-rw-r--r--kafka/consumer/group.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/kafka/consumer/group.py b/kafka/consumer/group.py
index 27ed4da..f9d0fb9 100644
--- a/kafka/consumer/group.py
+++ b/kafka/consumer/group.py
@@ -1086,9 +1086,7 @@ class KafkaConsumer(six.Iterator):
partitions = self._subscription.missing_fetch_positions()
self._update_fetch_positions(partitions)
- poll_ms = 1000 * (self._consumer_timeout - time.time())
- if not self._fetcher.in_flight_fetches():
- poll_ms = min(poll_ms, self.config['reconnect_backoff_ms'])
+ poll_ms = min((1000 * (self._consumer_timeout - time.time())), self.config['retry_backoff_ms'])
self._client.poll(timeout_ms=poll_ms)
# after the long poll, we should check whether the group needs to rebalance