Skip to content

Commit 8b3793a

Browse files
committed
Only use timeout if it's not None
1 parent 8cc36dd commit 8b3793a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

kafka/consumer.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def get_messages(self, count=1, block=True, timeout=0.1):
315315
it will block forever.
316316
"""
317317
messages = []
318-
if timeout:
318+
if timeout is not None:
319319
max_time = time.time() + timeout
320320

321321
while count > 0 and (timeout is None or timeout > 0):
@@ -328,7 +328,7 @@ def get_messages(self, count=1, block=True, timeout=0.1):
328328
if not block:
329329
# If we're not blocking, break.
330330
break
331-
if timeout:
331+
if timeout is not None:
332332
# If we're blocking and have a timeout, reduce it to the
333333
# appropriate value
334334
timeout = max_time - time.time()
@@ -610,7 +610,7 @@ def get_messages(self, count=1, block=True, timeout=10):
610610
self.size.value = count
611611
self.pause.clear()
612612

613-
if timeout:
613+
if timeout is not None:
614614
max_time = time.time() + timeout
615615

616616
while count > 0 and (timeout is None or timeout > 0):
@@ -633,7 +633,8 @@ def get_messages(self, count=1, block=True, timeout=10):
633633
self.count_since_commit += 1
634634
self._auto_commit()
635635
count -= 1
636-
timeout = max_time - time.time()
636+
if timeout is not None:
637+
timeout = max_time - time.time()
637638

638639
self.size.value = 0
639640
self.start.clear()

0 commit comments

Comments
 (0)