Skip to content

Commit

Permalink
Don't recheck version if api_versions data is already cached (#1738)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dpkp authored and jeffwidman committed Mar 14, 2019
1 parent 921c553 commit 1cd505d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions kafka/conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,9 @@ def _handle_api_version_response(self, response):
return self._api_versions

def get_api_versions(self):
if self._api_versions is not None:
return self._api_versions

version = self.check_version()
if version < (0, 10, 0):
raise Errors.UnsupportedVersionError(
Expand Down

0 comments on commit 1cd505d

Please # to comment.