diff --git a/main.py b/main.py index e038f6b..60f7b13 100644 --- a/main.py +++ b/main.py @@ -29,8 +29,8 @@ async def lifespan(app: FastAPI): consumer_task = asyncio.create_task(consume_messages()) yield - - await producer.stop() + if producer: + await producer.stop() consumer_task.cancel()