diff --git a/kafka/sasl/msk.py b/kafka/sasl/msk.py index 9d4f61f2e..a76e40135 100644 --- a/kafka/sasl/msk.py +++ b/kafka/sasl/msk.py @@ -11,12 +11,10 @@ from kafka.protocol.types import Int32 import kafka.errors as Errors -import boto3 -from botocore.session import Session as BotoSession - - def try_authenticate(self, future): + from botocore.session import Session as BotoSession # importing it in advance is not an option apparently... + session = BotoSession() credentials = session.get_credentials().get_frozen_credentials() client = AwsMskIamClient( diff --git a/test/test_msk.py b/test/test_msk.py index 4d06d4441..7c23e6eff 100644 --- a/test/test_msk.py +++ b/test/test_msk.py @@ -1,7 +1,7 @@ import datetime import json -from kafka.msk import AwsMskIamClient +from kafka.sasl.msk import AwsMskIamClient try: from unittest import mock @@ -11,7 +11,7 @@ def client_factory(token=None): now = datetime.datetime.utcfromtimestamp(1629321911) - with mock.patch('kafka.msk.datetime') as mock_dt: + with mock.patch('kafka.sasl.msk.datetime') as mock_dt: mock_dt.datetime.utcnow = mock.Mock(return_value=now) return AwsMskIamClient( host='localhost',