diff --git a/external/kafka/producer.py b/external/kafka/producer.py index 898bc8e..ab4e152 100644 --- a/external/kafka/producer.py +++ b/external/kafka/producer.py @@ -14,4 +14,4 @@ async def init_producer(): bootstrap_servers=KAFKA_URL, security_protocol='SSL', ssl_context=context, - ) + ) \ No newline at end of file diff --git a/main.py b/main.py index 4fa0cd7..e038f6b 100644 --- a/main.py +++ b/main.py @@ -21,7 +21,8 @@ origins = [ async def lifespan(app: FastAPI): try: await init_producer() - await producer.start() + if producer: + await producer.start() except KafkaConnectionError as e: print(e)