topics = subprocess.check_output([os.path.join(KAFKABIN, 'kafka-topics.sh'),
    '--list', '--zookeeper', '{}:2181'.format(KAFKAHOST)])
for wanted in wanted_topics:
    if wanted in topics:
        print("'{}' topic exists!".format(wanted))
else:
    print("'{}' topic does NOT exist!".format(wanted))
topic_desc = subprocess.check_output([os.path.join(KAFKABIN,
    'kafka-topics.sh'), '--describe', '--topic', wanted, '--zookeeper',
    '{}:2181'.format(KAFKAHOST)])
if not topic_desc:
    pass
Проверьте, существует ли тема Kafka в Python