async def disconnect(self):
if self.connection and not self.connection.is_closed:
logger.info(f"close RabbitMQ connection1")
try:
await self.connection.close()
logger.info(f"close RabbitMQ connection2")
except Exception as e:
logger.error(f"Failed to close RabbitMQ connection: {e}")
log
INFO: Shutting down
INFO: Waiting for application shutdown.
2024-07-26 16:42:28.703 | INFO | agentic.base.mq.client:disconnect:52 - close RabbitMQ connection1
async def disconnect(self): if self.connection and not self.connection.is_closed: logger.info(f"close RabbitMQ connection1") try: await self.connection.close() logger.info(f"close RabbitMQ connection2") except Exception as e: logger.error(f"Failed to close RabbitMQ connection: {e}")
async def on_shutdown(): await rabbit_mq.disconnect()
app.add_event_handler("shutdown", on_shutdown)
log INFO: Shutting down INFO: Waiting for application shutdown. 2024-07-26 16:42:28.703 | INFO | agentic.base.mq.client:disconnect:52 - close RabbitMQ connection1
The connection won't shut down