From e418b7c3b000375ec4d95c8b302cfec2e4efc85f Mon Sep 17 00:00:00 2001 From: Jeff Widman Date: Thu, 5 Oct 2017 22:20:42 -0700 Subject: 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. --- kafka/coordinator/consumer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v1.2.1