Skip to content

Commit eb755b3

Browse files
author
Dana Powers
committed
Fix SimpleConsumer timeout behavior in get_messages (Issue 237)
1 parent 29f5619 commit eb755b3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

kafka/consumer/simple.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,11 @@ def get_messages(self, count=1, block=True, timeout=0.1):
207207
if not block:
208208
# If we're not blocking, break.
209209
break
210-
if timeout is not None:
211-
# If we're blocking and have a timeout, reduce it to the
212-
# appropriate value
213-
timeout = max_time - time.time()
210+
211+
# If we have a timeout, reduce it to the
212+
# appropriate value
213+
if timeout is not None:
214+
timeout = max_time - time.time()
214215

215216
# Update and commit offsets if necessary
216217
self.offsets.update(new_offsets)

0 commit comments

Comments
 (0)