From 43939b29b58d85cef325cb4dba67a413b6f735d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0ebek?= Date: Fri, 7 Jul 2017 21:29:40 +0200 Subject: change_subscription called only when necessary (#1132) When we are using subscription by pattern change subscription is called every metadata update even when nothing changes. This PR ensures that change subscription is called only when set of topics changes. --- kafka/coordinator/consumer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'kafka/coordinator/consumer.py') diff --git a/kafka/coordinator/consumer.py b/kafka/coordinator/consumer.py index 00b8b6b..71a93ec 100644 --- a/kafka/coordinator/consumer.py +++ b/kafka/coordinator/consumer.py @@ -140,8 +140,9 @@ class ConsumerCoordinator(BaseCoordinator): if self._subscription.subscribed_pattern.match(topic): topics.append(topic) - self._subscription.change_subscription(topics) - self._client.set_topics(self._subscription.group_subscription()) + if set(topics) != self._subscription.subscription: + self._subscription.change_subscription(topics) + self._client.set_topics(self._subscription.group_subscription()) # check if there are any changes to the metadata which should trigger # a rebalance -- cgit v1.2.1