完成项目信息管理的迁移
This commit is contained in:
@ -10,13 +10,10 @@
|
||||
from fastapi import FastAPI
|
||||
from motor.motor_asyncio import AsyncIOMotorClient
|
||||
from application.settings import REDIS_DB_URL, MONGO_DB_URL, MONGO_DB_NAME, EVENTS
|
||||
from utils.cache import Cache
|
||||
from redis import asyncio as aioredis
|
||||
from redis.exceptions import AuthenticationError, TimeoutError, RedisError
|
||||
from contextlib import asynccontextmanager
|
||||
from utils.tools import import_modules_async
|
||||
from sqlalchemy.exc import ProgrammingError
|
||||
from core.logger import logger
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
@ -79,11 +76,6 @@ async def connect_redis(app: FastAPI, status: bool):
|
||||
raise TimeoutError(f"Redis 连接超时,地址或者端口错误: {e}")
|
||||
except RedisError as e:
|
||||
raise RedisError(f"Redis 连接失败: {e}")
|
||||
try:
|
||||
await Cache(app.state.redis).cache_tab_names()
|
||||
except ProgrammingError as e:
|
||||
logger.error(f"sqlalchemy.exc.ProgrammingError: {e}")
|
||||
print(f"sqlalchemy.exc.ProgrammingError: {e}")
|
||||
else:
|
||||
print("Redis 连接关闭")
|
||||
await app.state.redis.close()
|
||||
|
Reference in New Issue
Block a user