from kafkatest.services.kafka import KafkaService kafka = KafkaService() kafka.start() # do some work with the Kafka broker kafka.stop()
from kafkatest.services.kafka import KafkaService kafka = KafkaService() kafka.start() # do some work with the Kafka broker kafka.stop(graceful=False)This example creates a new KafkaService, starts the broker, performs some work with the broker, and then stops it immediately without waiting for any in-flight requests to complete. The `graceful` parameter default value is True. Overall, the KafkaService class provides a convenient way to start, manage, and stop a Kafka broker from within a Python program.