summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kafka/client_async.py8
-rw-r--r--kafka/conn.py8
2 files changed, 12 insertions, 4 deletions
diff --git a/kafka/client_async.py b/kafka/client_async.py
index 03a2f00..bd9bf2e 100644
--- a/kafka/client_async.py
+++ b/kafka/client_async.py
@@ -578,6 +578,14 @@ class KafkaClient(object):
if response:
responses.append(response)
+ for conn in six.itervalues(self._conns):
+ if conn.requests_timed_out():
+ log.warning('%s timed out after %s ms. Closing connection.',
+ conn, conn.config['request_timeout_ms'])
+ conn.close(error=Errors.RequestTimedOutError(
+ 'Request timed out after %s ms' %
+ conn.config['request_timeout_ms']))
+
if self._sensors:
self._sensors.io_time.record((time.time() - end_select) * 1000000000)
return responses
diff --git a/kafka/conn.py b/kafka/conn.py
index b451895..21607d9 100644
--- a/kafka/conn.py
+++ b/kafka/conn.py
@@ -575,15 +575,15 @@ class BrokerConnection(object):
log.warning('%s: No in-flight-requests to recv', self)
return None
- elif self._requests_timed_out():
+ response = self._recv()
+ if not response and self.requests_timed_out():
log.warning('%s timed out after %s ms. Closing connection.',
self, self.config['request_timeout_ms'])
self.close(error=Errors.RequestTimedOutError(
'Request timed out after %s ms' %
self.config['request_timeout_ms']))
return None
-
- return self._recv()
+ return response
def _recv(self):
# Not receiving is the state of reading the payload header
@@ -719,7 +719,7 @@ class BrokerConnection(object):
self._processing = False
return response
- def _requests_timed_out(self):
+ def requests_timed_out(self):
if self.in_flight_requests:
oldest_at = self.in_flight_requests[0].timestamp
timeout = self.config['request_timeout_ms'] / 1000.0