Skip to content

Commit 3aa55a6

Browse files
committed
Improve too-large timeout handling in client poll
1 parent 3c6def9 commit 3aa55a6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

kafka/client_async.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,11 @@ def _register_send_sockets(self):
672672
self._selector.register(conn._sock, selectors.EVENT_WRITE, conn)
673673

674674
def _poll(self, timeout):
675+
# Python throws OverflowError if timeout is > 2147483647 milliseconds
676+
# (though the param to selector.select is in seconds)
677+
# so convert any too-large timeout to blocking
678+
if timeout > 2147483:
679+
timeout = None
675680
# This needs to be locked, but since it is only called from within the
676681
# locked section of poll(), there is no additional lock acquisition here
677682
processed = set()
@@ -680,8 +685,6 @@ def _poll(self, timeout):
680685
self._register_send_sockets()
681686

682687
start_select = time.time()
683-
if timeout == float('inf'):
684-
timeout = None
685688
ready = self._selector.select(timeout)
686689
end_select = time.time()
687690
if self._sensors:

0 commit comments

Comments
 (0)