P1-7(部分): 3个潜伏bug修复 - main.py app_root未定义/scheduler.py AsyncIOSScheduler拼写/config.py logger未定义
This commit is contained in:
@@ -6,12 +6,16 @@
|
|||||||
# 所有配置项集中管理,避免散落在代码各处
|
# 所有配置项集中管理,避免散落在代码各处
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
import redis.asyncio as aioredis
|
import redis.asyncio as aioredis
|
||||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||||
|
|
||||||
|
# v4.0 P1-7 修复:get_automation_thresholds 异常分支使用 logger 但未定义
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Settings(BaseSettings):
|
class Settings(BaseSettings):
|
||||||
"""应用配置类。
|
"""应用配置类。
|
||||||
|
|||||||
@@ -1014,6 +1014,10 @@ def create_app() -> FastAPI:
|
|||||||
返回服务版本信息。
|
返回服务版本信息。
|
||||||
"""
|
"""
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
# v4.0 P1-7 修复:app_root 之前未定义导致 git_hash 永远 "unknown"
|
||||||
|
# 项目根 = app/main.py 的上两级(容器内为 /app)
|
||||||
|
app_root = Path(__file__).resolve().parents[1]
|
||||||
try:
|
try:
|
||||||
git_hash = subprocess.check_output(
|
git_hash = subprocess.check_output(
|
||||||
["git", "rev-parse", "HEAD"],
|
["git", "rev-parse", "HEAD"],
|
||||||
|
|||||||
@@ -18,7 +18,9 @@ from apscheduler.triggers.cron import CronTrigger
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# 定时任务调度器实例
|
# 定时任务调度器实例
|
||||||
scheduler = AsyncIOSScheduler()
|
# v4.0 P1-7 修复:AsyncIOSScheduler → AsyncIOScheduler(原拼写错误,import 即 NameError)
|
||||||
|
# 注意:本模块当前无人 import(main.py 使用自己的 _scheduler),批次 4 候选删除
|
||||||
|
scheduler = AsyncIOScheduler()
|
||||||
|
|
||||||
|
|
||||||
def setup_scheduled_tasks():
|
def setup_scheduled_tasks():
|
||||||
|
|||||||
Reference in New Issue
Block a user