mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-07 00:16:57 +08:00
refactor: use explicit runtime facade getters
This commit is contained in:
@@ -24,7 +24,7 @@ from app.api.dependencies.history import get_dashboard_query_service
|
||||
from app.application.dashboard import DashboardQueryService
|
||||
from app.schemas.types import StorageAction
|
||||
from app.application.directory import DirectoryHelper
|
||||
from app.application.scheduling import Scheduler
|
||||
from app.application.scheduling import get_scheduler
|
||||
from app.adapters.system.host import SystemUtils
|
||||
|
||||
router = ResponseAPIRouter()
|
||||
@@ -180,7 +180,7 @@ async def schedule(_: Any = Depends(get_current_active_superuser)) -> Any:
|
||||
查询后台服务信息
|
||||
"""
|
||||
# 同步 list() 内含同步进度读取,放到线程池执行避免阻塞事件循环
|
||||
return await run_in_threadpool(Scheduler().list)
|
||||
return await run_in_threadpool(get_scheduler().list)
|
||||
|
||||
|
||||
@router.get(
|
||||
@@ -195,7 +195,7 @@ async def schedule_progress(
|
||||
查询指定后台服务的执行进度。
|
||||
"""
|
||||
# 异步进度后端读取,避免同步 Redis 调用阻塞事件循环
|
||||
progress = await Scheduler().aget_progress(job_id)
|
||||
progress = await get_scheduler().aget_progress(job_id)
|
||||
if not progress:
|
||||
return _SchemaResponse(success=False, message="后台服务不存在")
|
||||
return _SchemaResponse(success=True, data=progress.model_dump())
|
||||
@@ -211,7 +211,7 @@ async def schedule2(_: Annotated[str, Depends(verify_apitoken)]) -> Any:
|
||||
查询下载器信息 API_TOKEN认证(?token=xxx)
|
||||
"""
|
||||
# 同步 list() 内含同步进度读取,放到线程池执行避免阻塞事件循环
|
||||
return await run_in_threadpool(Scheduler().list)
|
||||
return await run_in_threadpool(get_scheduler().list)
|
||||
|
||||
|
||||
@router.get(
|
||||
@@ -226,7 +226,7 @@ async def schedule_progress2(
|
||||
查询指定后台服务的执行进度 API_TOKEN认证(?token=xxx)
|
||||
"""
|
||||
# 异步进度后端读取,避免同步 Redis 调用阻塞事件循环
|
||||
progress = await Scheduler().aget_progress(job_id)
|
||||
progress = await get_scheduler().aget_progress(job_id)
|
||||
if not progress:
|
||||
return _SchemaResponse(success=False, message="后台服务不存在")
|
||||
return _SchemaResponse(success=True, data=progress.model_dump())
|
||||
|
||||
Reference in New Issue
Block a user