From fc21b158aa5b978088514a1f8048fe38d15f7d4f Mon Sep 17 00:00:00 2001 From: martsforever Date: Tue, 9 Dec 2025 17:46:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4=20nltk=20=E7=9A=84?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E6=97=B6=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/create_app.py | 2 +- app/utils/db_utils.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/create_app.py b/app/create_app.py index 6972ec1..ac81bd9 100644 --- a/app/create_app.py +++ b/app/create_app.py @@ -19,12 +19,12 @@ def create_app(): @asynccontextmanager async def lifespan(app: FastAPI): print("lifespan:启动阶段") + await check_nltk() async_results = await asyncio.gather( asyncio.create_task(check_database_connection()), asyncio.create_task(check_postgres_connection()), asyncio.create_task(milvus_service.check_milvus_connection()), asyncio.create_task(redis_utils.check_redis_connection()), - asyncio.create_task(check_nltk()), ) async_engine = async_results[0] yield diff --git a/app/utils/db_utils.py b/app/utils/db_utils.py index 7e15641..3ad777d 100644 --- a/app/utils/db_utils.py +++ b/app/utils/db_utils.py @@ -22,7 +22,8 @@ async_engine = AsyncEngine(create_engine( pool_size=5, # 连接池保持的连接数 max_overflow=10, # 允许超过pool_size的最大连接数 pool_timeout=30, # 获取连接的超时时间(秒) - pool_recycle=300, # 连接回收时间(秒) + pool_recycle=180, # 连接回收时间(秒) + pool_pre_ping=True, # 启用连接有效性检测 echo=True, # 启用SQL语句日志输出,便于开发调试 future=True, # 启用SQLAlchemy 2.0风格的未来模式API ))