kafka-python icon indicating copy to clipboard operation
kafka-python copied to clipboard

`KafkaConsumer.poll()` does not poll messages with default value for `timeout_ms`

Open alexwalterbos opened this issue 2 months ago • 1 comments

When using KafkaConsumer.poll() without specifying timeout_ns, the default value 0 is used. This seems to trigger the early exit here: https://github.com/dpkp/kafka-python/blob/master/kafka/consumer/group.py#L727

With a nonzero timeout_ns, the poll fetches messages just fine.

Similar to https://github.com/dpkp/kafka-python/issues/2609, but seems not to have been fixed.

Let me know if you need more information.

alexwalterbos avatar Nov 12 '25 07:11 alexwalterbos

Do you have logs with more details? The expected behavior is that there is no IO blocking within poll() that lasts longer than the timeout value. If timeout is 0 then you should see non-blocking IO, which means you'd need to call poll() multiple times -- with some delay to wait for IO to complete -- before you start receiving messages.

dpkp avatar Nov 18 '25 23:11 dpkp