Skip to content

Commit 7adc692

Browse files
author
Petr Šebek
committed
change_subscription called only when necessary
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 b8da199 commit 7adc692

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

kafka/coordinator/consumer.py

Lines changed: 3 additions & 2 deletions
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)