diff options
author | Petr Ĺ ebek <petrsebek1@gmail.com> | 2017-07-07 21:29:40 +0200 |
---|---|---|
committer | Dana Powers <dana.powers@gmail.com> | 2017-07-07 12:29:40 -0700 |
commit | 43939b29b58d85cef325cb4dba67a413b6f735d8 (patch) | |
tree | af4f3547b43d983f6786e5acbd177d23a179dd24 | |
parent | 71ce772484cb43509742702c3f09ec7fde2923f7 (diff) | |
download | kafka-python-43939b29b58d85cef325cb4dba67a413b6f735d8.tar.gz |
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.
-rw-r--r-- | kafka/coordinator/consumer.py | 5 |
1 files changed, 3 insertions, 2 deletions
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 |