Skip to content

Commit dcab356

Browse files
committed
Improve too-large timeout handling in client poll
1 parent 43a8b74 commit dcab356

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

kafka/client_async.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,11 @@ def _register_send_sockets(self):
631631
self._selector.register(conn._sock, selectors.EVENT_WRITE, conn)
632632

633633
def _poll(self, timeout):
634+
# Python throws OverflowError if timeout is > 2147483647 milliseconds
635+
# (though the param to selector.select is in seconds)
636+
# so convert any too-large timeout to blocking
637+
if timeout > 2147483:
638+
timeout = None
634639
# This needs to be locked, but since it is only called from within the
635640
# locked section of poll(), there is no additional lock acquisition here
636641
processed = set()
@@ -639,8 +644,6 @@ def _poll(self, timeout):
639644
self._register_send_sockets()
640645

641646
start_select = time.time()
642-
if timeout == float('inf'):
643-
timeout = None
644647
ready = self._selector.select(timeout)
645648
end_select = time.time()
646649
if self._sensors:

0 commit comments

Comments
 (0)