diff --git a/kafka/sasl/__init__.py b/kafka/sasl/__init__.py index 337c90949..dc9456d5a 100644 --- a/kafka/sasl/__init__.py +++ b/kafka/sasl/__init__.py @@ -1,8 +1,6 @@ import logging -from kafka.sasl import gssapi, oauthbearer, plain, scram, msk - -log = logging.getLogger(__name__) +from kafka.sasl import gssapi, oauthbearer, plain, scram MECHANISMS = { 'GSSAPI': gssapi, @@ -10,9 +8,16 @@ 'PLAIN': plain, 'SCRAM-SHA-256': scram, 'SCRAM-SHA-512': scram, - 'AWS_MSK_IAM': msk, } +try: + from kafka.sasl import msk + MECHANISMS['AWS_MSK_IAM'] = msk +except ImportError: + pass + +log = logging.getLogger(__name__) + def register_mechanism(key, module): """