AI问数二期
This commit is contained in:
+11
-4
@@ -27,6 +27,7 @@ from routers.dify_export_router import difyRouter
|
||||
from service.RabbitMQ import (
|
||||
mq_client,
|
||||
)
|
||||
from service.cube_metadata import warm_cube_metadata_cache
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
@@ -35,10 +36,16 @@ async def lifespan(app: FastAPI):
|
||||
await mq_client.init()
|
||||
# 启动消费者
|
||||
await mq_client.start_all_consumer()
|
||||
yield
|
||||
# 应用关闭时关闭 MQ 连接
|
||||
if mq_client._connection:
|
||||
await mq_client._connection.close()
|
||||
cube_metadata_task = asyncio.create_task(warm_cube_metadata_cache())
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
if not cube_metadata_task.done():
|
||||
cube_metadata_task.cancel()
|
||||
await asyncio.gather(cube_metadata_task, return_exceptions=True)
|
||||
# 应用关闭时关闭 MQ 连接
|
||||
if mq_client._connection:
|
||||
await mq_client._connection.close()
|
||||
|
||||
|
||||
async def ai_lab():
|
||||
|
||||
Reference in New Issue
Block a user