summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Widman <jeff@jeffwidman.com>2017-10-05 22:20:42 -0700
committerJeff Widman <jeff@jeffwidman.com>2017-10-06 14:44:04 -0700
commit411bc08f214b7afc36f11bde2047096c06467088 (patch)
tree4e4b70318210b34b80a9c80345739b588e514caa
parentffc7caef13a120f69788bcdd43ffa01468f575f9 (diff)
downloadkafka-python-411bc08f214b7afc36f11bde2047096c06467088.tar.gz
Explicitly check for `None` rather than False
If the group leader somehow gets in a state that it has an empty partition assignment, then `self._assignment_snapshot` will be `{}` which evaluates to `False`. So `self._subscription.mark_for_reassignment()` will never be triggered, even if `self._assignment_snapshot != self._metadata_snapshot`. Fixes the symptoms of https://github.com/dpkp/kafka-python/issues/1237 although I suspect there's an additional bug in that case that triggers the condition of the the group leader getting an empty partition assignment.
-rw-r--r--kafka/coordinator/consumer.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/kafka/coordinator/consumer.py b/kafka/coordinator/consumer.py
index 123699f..84c62df 100644
--- a/kafka/coordinator/consumer.py
+++ b/kafka/coordinator/consumer.py
@@ -190,7 +190,7 @@ class ConsumerCoordinator(BaseCoordinator):
# if we were the assignor, then we need to make sure that there have
# been no metadata updates since the rebalance begin. Otherwise, we
# won't rebalance again until the next metadata change
- if self._assignment_snapshot and self._assignment_snapshot != self._metadata_snapshot:
+ if self._assignment_snapshot is not None and self._assignment_snapshot != self._metadata_snapshot:
self._subscription.mark_for_reassignment()
return