Skip to content

Commit 99da57f

Browse files
committed
Added some comments about message state
1 parent b022be2 commit 99da57f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

kafka/consumer.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,13 @@ def __iter_partition__(self, partition, offset):
365365
next_offset = None
366366
for message in resp.messages:
367367
next_offset = message.offset
368+
369+
# update the offset before the message is yielded. This is
370+
# so that the consumer state is not lost in certain cases.
371+
# For eg: the message is yielded and consumed by the caller,
372+
# but the caller does not come back into the generator again.
373+
# The message will be consumed but the status will not be
374+
# updated in the consumer
368375
self.offsets[partition] = message.offset
369376
yield message
370377
if next_offset is None:

0 commit comments

Comments
 (0)