Skip to content

Commit a7d8ae5

Browse files
committed
Avoid sys.maxint; not supported on py3
1 parent 645129b commit a7d8ae5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

kafka/consumer/fetcher.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ def _message_generator(self):
400400

401401
tp = self._next_partition_records.topic_partition
402402

403-
for msg in self._next_partition_records.take(sys.maxint):
403+
for msg in self._next_partition_records.take():
404404

405405
# Because we are in a generator, it is possible for
406406
# subscription state to change between yield calls
@@ -881,9 +881,11 @@ def __len__(self):
881881
def discard(self):
882882
self.messages = None
883883

884-
def take(self, n):
884+
def take(self, n=None):
885885
if not len(self):
886886
return []
887+
if n is None or n > len(self):
888+
n = len(self)
887889
next_idx = self.message_idx + n
888890
res = self.messages[self.message_idx:next_idx]
889891
self.message_idx = next_idx

0 commit comments

Comments
 (0)