Skip to content

Commit af1a5f0

Browse files
authored
Update __init__.py of SASL to catch ImportErrors in case botocore is not installed (dpkp#175)
Closes kafka-python-ng#174.
1 parent cbf317b commit af1a5f0

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

kafka/sasl/__init__.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
import logging
22

3-
from kafka.sasl import gssapi, oauthbearer, plain, scram, msk
4-
5-
log = logging.getLogger(__name__)
3+
from kafka.sasl import gssapi, oauthbearer, plain, scram
64

75
MECHANISMS = {
86
'GSSAPI': gssapi,
97
'OAUTHBEARER': oauthbearer,
108
'PLAIN': plain,
119
'SCRAM-SHA-256': scram,
1210
'SCRAM-SHA-512': scram,
13-
'AWS_MSK_IAM': msk,
1411
}
1512

13+
try:
14+
from kafka.sasl import msk
15+
MECHANISMS['AWS_MSK_IAM'] = msk
16+
except ImportError:
17+
pass
18+
19+
log = logging.getLogger(__name__)
20+
1621

1722
def register_mechanism(key, module):
1823
"""

0 commit comments

Comments
 (0)