Skip to content

Commit 1cd505d

Browse files
dpkpjeffwidman
authored andcommitted
Don't recheck version if api_versions data is already cached (#1738)
I noticed during local testing that version probing was happening twice when connecting to newer broker versions. This was because we call check_version() once explicitly, and then again implicitly within get_api_versions(). But once we have _api_versions data cached, we can just return it and avoid probing versions a second time.
1 parent 921c553 commit 1cd505d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

kafka/conn.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,9 @@ def _handle_api_version_response(self, response):
912912
return self._api_versions
913913

914914
def get_api_versions(self):
915+
if self._api_versions is not None:
916+
return self._api_versions
917+
915918
version = self.check_version()
916919
if version < (0, 10, 0):
917920
raise Errors.UnsupportedVersionError(

0 commit comments

Comments
 (0)