Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions kafka/conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,7 @@ def connect_blocking(self, timeout=float('inf')):
# First attempt to perform dns lookup
# note that the underlying interface, socket.getaddrinfo,
# has no explicit timeout so we may exceed the user-specified timeout
while time.time() < timeout:
if self._dns_lookup():
break
else:
return False
self._dns_lookup()

# Loop once over all returned dns entries
selector = None
Expand Down Expand Up @@ -903,6 +899,7 @@ def check_version(self, timeout=2, strict=False):

Returns: version tuple, i.e. (0, 10), (0, 9), (0, 8, 2), ...
"""
timeout_at = time.time() + timeout
log.info('Probing node %s broker version', self.node_id)
# Monkeypatch some connection configurations to avoid timeouts
override_config = {
Expand Down Expand Up @@ -932,7 +929,7 @@ def check_version(self, timeout=2, strict=False):
]

for version, request in test_cases:
if not self.connect_blocking(timeout):
if not self.connect_blocking(timeout_at - time.time()):
raise Errors.NodeNotReadyError()
f = self.send(request)
# HACK: sleeping to wait for socket to send bytes
Expand Down