From 4e93904d186d56f03a9912ed3ff847a9ff692369 Mon Sep 17 00:00:00 2001 From: Dana Powers Date: Wed, 13 Mar 2019 18:33:38 -0700 Subject: Recheck connecting nodes sooner when refreshing metadata --- kafka/client_async.py | 4 +--- test/test_client_async.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/kafka/client_async.py b/kafka/client_async.py index d608e6a..b2ea286 100644 --- a/kafka/client_async.py +++ b/kafka/client_async.py @@ -825,9 +825,7 @@ class KafkaClient(object): # the client from unnecessarily connecting to additional nodes while a previous connection # attempt has not been completed. if self._connecting: - # Strictly the timeout we should return here is "connect timeout", but as we don't - # have such application level configuration, using request timeout instead. - return self.config['request_timeout_ms'] + return self.config['reconnect_backoff_ms'] if self.maybe_connect(node_id): log.debug("Initializing connection to node %s for metadata request", node_id) diff --git a/test/test_client_async.py b/test/test_client_async.py index 1c8a50f..a4dc9db 100644 --- a/test/test_client_async.py +++ b/test/test_client_async.py @@ -376,7 +376,7 @@ def test_maybe_refresh_metadata_cant_send(mocker, client): client._connecting.add('foobar') client._can_connect.reset_mock() client.poll(timeout_ms=12345678) - client._poll.assert_called_with(9999.999) # connection timeout (request timeout) + client._poll.assert_called_with(2.222) # connection timeout (reconnect timeout) assert not client._can_connect.called assert not client._metadata_refresh_in_progress -- cgit v1.2.1