summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDana Powers <dana.powers@gmail.com>2019-12-29 16:01:20 -0800
committerGitHub <noreply@github.com>2019-12-29 16:01:20 -0800
commit23534b45b8362e4a0e6b5d8b2fa86cb68cf38e08 (patch)
treedb83d335ca01bd82c3d8a0d393effc276d0ea1c6
parent3aada777e9c3bbb5751a15b615d6fbe4693cc6f0 (diff)
downloadkafka-python-23534b45b8362e4a0e6b5d8b2fa86cb68cf38e08.tar.gz
Raise AssertionError if consumer closed in poll() (#1978)
-rw-r--r--kafka/consumer/group.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/kafka/consumer/group.py b/kafka/consumer/group.py
index 8474b7c..eb7dff2 100644
--- a/kafka/consumer/group.py
+++ b/kafka/consumer/group.py
@@ -638,6 +638,7 @@ class KafkaConsumer(six.Iterator):
max_records = self.config['max_poll_records']
assert isinstance(max_records, int), 'max_records must be an integer'
assert max_records > 0, 'max_records must be positive'
+ assert not self._closed, 'KafkaConsumer is closed'
# Poll for new data until the timeout expires
start = time.time()
@@ -1173,6 +1174,8 @@ class KafkaConsumer(six.Iterator):
return self
def __next__(self):
+ if self._closed:
+ raise StopIteration('KafkaConsumer closed')
# Now that the heartbeat thread runs in the background
# there should be no reason to maintain a separate iterator
# but we'll keep it available for a few releases just in case