Skip to content

Commit 7d425d0

Browse files
author
Mark Roberts
committed
Commit in seek if autocommit
1 parent e5af317 commit 7d425d0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

kafka/consumer.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ def seek(self, offset, whence):
275275
2 is relative to the latest known offset (tail)
276276
"""
277277

278-
self.count_since_commit += 1
279278
if whence == 1: # relative to current position
280279
for partition, _offset in self.offsets.items():
281280
self.offsets[partition] = _offset + offset
@@ -306,6 +305,10 @@ def seek(self, offset, whence):
306305

307306
# Reset queue and fetch offsets since they are invalid
308307
self.fetch_offsets = self.offsets.copy()
308+
if self.auto_commit:
309+
self.count_since_commit += 1
310+
self.commit()
311+
309312
self.queue = Queue()
310313

311314
def get_messages(self, count=1, block=True, timeout=0.1):

0 commit comments

Comments
 (0)