refactor: 收敛 factory 模块级副作用并统一 async 路径进度为异步后端

- 将 configure_token_codec/configure_plugin_routes 移入 create_app(),消除 import 期副作用
- runtime 层新增 AsyncCacheProxy/AsyncTTLCache/AsyncProgressHelper,共享 progress region
- search/system/history/scheduler/dashboard 的事件循环路径切换异步进度后端
- 同步进度回调经事件循环提交或线程池执行,避免阻塞事件循环
This commit is contained in:
jxxghp
2026-08-19 09:11:42 +08:00
parent 91d339a8dd
commit 03ada7eb01
9 changed files with 446 additions and 105 deletions
+3 -3
View File
@@ -52,7 +52,7 @@ from app.adapters.external.market import (
split_plugin_market_repo_urls,
)
from app.application.messaging.message import MessageHelper
from app.runtime.progress import ProgressHelper
from app.runtime.progress import AsyncProgressHelper
from app.application.rules import RuleHelper
from app.adapters.external.server import MoviePilotServerHelper
from app.runtime.state import SystemHelper
@@ -847,7 +847,7 @@ async def get_progress(
"""
实时获取处理进度,返回格式为SSE
"""
progress = ProgressHelper(process_type)
progress = AsyncProgressHelper(process_type)
locale = LocaleHelper.get_current_locale()
async def event_generator():
@@ -855,7 +855,7 @@ async def get_progress(
while not global_vars.is_system_stopped:
if await request.is_disconnected():
break
detail = progress.get(locale=locale)
detail = await progress.get(locale=locale)
yield f"data: {json.dumps(detail)}\n\n"
await asyncio.sleep(0.5)
except asyncio.CancelledError: