Skip to content

Commit 43939b2

Browse files
Artimidpkp
authored andcommitted
change_subscription called only when necessary (dpkp#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.
1 parent 71ce772 commit 43939b2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

kafka/coordinator/consumer.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,9 @@ def _handle_metadata_update(self, cluster):
140140
if self._subscription.subscribed_pattern.match(topic):
141141
topics.append(topic)
142142

143-
self._subscription.change_subscription(topics)
144-
self._client.set_topics(self._subscription.group_subscription())
143+
if set(topics) != self._subscription.subscription:
144+
self._subscription.change_subscription(topics)
145+
self._client.set_topics(self._subscription.group_subscription())
145146

146147
# check if there are any changes to the metadata which should trigger
147148
# a rebalance

0 commit comments

Comments
 (0)