Skip to content

Commit 2e3d6db

Browse files
committed
Merge pull request dpkp#238 from dpkp/simple_consumer_get_messages_timeout
Fix SimpleConsumer timeout behavior in get_messages (Issue 237)
2 parents 29f5619 + eb755b3 commit 2e3d6db

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)