Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recheck connecting nodes sooner when refreshing metadata #1737

Merged
merged 1 commit into from
Mar 14, 2019
Merged
Show file tree
Hide file tree
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
4 changes: 1 addition & 3 deletions kafka/client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,9 +825,7 @@ def refresh_done(val_or_error):
# 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)
Expand Down
2 changes: 1 addition & 1 deletion test/test_client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down