Skip to content

Commit deb584c

Browse files
mrthebmumrah
authored andcommitted
Cherry-pick mrtheb/kafka-python 2b016b6
Set FetchRequest MaxBytes value to bufsize instead of fetchsize (=MinBytes)
1 parent c304e3d commit deb584c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

kafka/consumer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,10 @@ def __iter_partition__(self, partition, offset):
359359
fetch_size = self.fetch_min_bytes
360360

361361
while True:
362-
req = FetchRequest(self.topic, partition, offset, fetch_size)
362+
# use MaxBytes = client's bufsize since we're only
363+
# fetching one topic + partition
364+
req = FetchRequest(
365+
self.topic, partition, offset, self.client.bufsize)
363366

364367
(resp,) = self.client.send_fetch_request([req],
365368
max_wait_time=self.fetch_max_wait_time,

kafka/util.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,17 @@ def read_short_string(data, cur):
3838

3939
def read_int_string(data, cur):
4040
if len(data) < cur + 4:
41-
raise BufferUnderflowError("Not enough data left")
41+
raise BufferUnderflowError(
42+
"Not enough data left to read string len (%d < %d)" % (len(data), cur + 4))
4243

4344
(strLen,) = struct.unpack('>i', data[cur:cur + 4])
4445
if strLen == -1:
4546
return (None, cur + 4)
4647

4748
cur += 4
4849
if len(data) < cur + strLen:
49-
raise BufferUnderflowError("Not enough data left")
50+
raise BufferUnderflowError(
51+
"Not enough data left to read string (%d < %d)" % (len(data), cur + strLen))
5052

5153
out = data[cur:cur + strLen]
5254
return (out, cur + strLen)
@@ -68,7 +70,6 @@ def group_by_topic_and_partition(tuples):
6870
return out
6971

7072

71-
7273
class ReentrantTimer(object):
7374
"""
7475
A timer that can be restarted, unlike threading.Timer

0 commit comments

Comments
 (0)