mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-06 07:56:52 +08:00
refactor: unify host threadpool boundary
This commit is contained in:
+14
-2
@@ -13,8 +13,8 @@
|
||||
"runtime_to_db": [],
|
||||
"workflow_to_db": []
|
||||
},
|
||||
"edge_count": 6532,
|
||||
"edge_sha256": "3fdba2c6862f9ea28ab4f059c04dd6bb819b86fa9d9fb74d09a0cfcf69f6b711",
|
||||
"edge_count": 6544,
|
||||
"edge_sha256": "44812359c634235d327fdc499bc0ccf93e24923fba24bed4a29fc14adc26bf84",
|
||||
"edges": [
|
||||
"app -> app.runtime",
|
||||
"app -> app.runtime.compat",
|
||||
@@ -180,6 +180,7 @@
|
||||
"app.agent.callback -> app.agent.policy.sanitizer",
|
||||
"app.agent.callback -> app.chain",
|
||||
"app.agent.callback -> app.runtime",
|
||||
"app.agent.callback -> app.runtime.execution",
|
||||
"app.agent.callback -> app.runtime.log",
|
||||
"app.agent.callback -> app.schemas",
|
||||
"app.agent.callback -> app.schemas.message",
|
||||
@@ -363,6 +364,7 @@
|
||||
"app.agent.orchestrator -> app.foundation.identity",
|
||||
"app.agent.orchestrator -> app.runtime",
|
||||
"app.agent.orchestrator -> app.runtime.events",
|
||||
"app.agent.orchestrator -> app.runtime.execution",
|
||||
"app.agent.orchestrator -> app.runtime.log",
|
||||
"app.agent.orchestrator -> app.runtime.observability",
|
||||
"app.agent.orchestrator -> app.runtime.settings",
|
||||
@@ -1674,6 +1676,7 @@
|
||||
"app.api.endpoints.agent -> app.runtime",
|
||||
"app.api.endpoints.agent -> app.runtime.config",
|
||||
"app.api.endpoints.agent -> app.runtime.events",
|
||||
"app.api.endpoints.agent -> app.runtime.execution",
|
||||
"app.api.endpoints.agent -> app.runtime.localization",
|
||||
"app.api.endpoints.agent -> app.runtime.log",
|
||||
"app.api.endpoints.agent -> app.schemas",
|
||||
@@ -1760,6 +1763,8 @@
|
||||
"app.api.endpoints.dashboard -> app.chain",
|
||||
"app.api.endpoints.dashboard -> app.chain.dashboard",
|
||||
"app.api.endpoints.dashboard -> app.chain.storage",
|
||||
"app.api.endpoints.dashboard -> app.runtime",
|
||||
"app.api.endpoints.dashboard -> app.runtime.execution",
|
||||
"app.api.endpoints.dashboard -> app.schemas",
|
||||
"app.api.endpoints.dashboard -> app.schemas.dashboard",
|
||||
"app.api.endpoints.dashboard -> app.schemas.response",
|
||||
@@ -2095,6 +2100,7 @@
|
||||
"app.api.endpoints.plugin -> app.application.scheduling",
|
||||
"app.api.endpoints.plugin -> app.runtime",
|
||||
"app.api.endpoints.plugin -> app.runtime.cache",
|
||||
"app.api.endpoints.plugin -> app.runtime.execution",
|
||||
"app.api.endpoints.plugin -> app.runtime.extensions",
|
||||
"app.api.endpoints.plugin -> app.runtime.extensions.plugin",
|
||||
"app.api.endpoints.plugin -> app.runtime.extensions.plugin.contracts",
|
||||
@@ -2985,6 +2991,7 @@
|
||||
"app.chain._recognition -> app.runtime",
|
||||
"app.chain._recognition -> app.runtime.cache",
|
||||
"app.chain._recognition -> app.runtime.events",
|
||||
"app.chain._recognition -> app.runtime.execution",
|
||||
"app.chain._recognition -> app.runtime.log",
|
||||
"app.chain._recognition -> app.schemas",
|
||||
"app.chain._recognition -> app.schemas.media",
|
||||
@@ -3152,6 +3159,7 @@
|
||||
"app.chain.media -> app.runtime",
|
||||
"app.chain.media -> app.runtime.cache",
|
||||
"app.chain.media -> app.runtime.events",
|
||||
"app.chain.media -> app.runtime.execution",
|
||||
"app.chain.media -> app.runtime.log",
|
||||
"app.chain.media -> app.schemas",
|
||||
"app.chain.media -> app.schemas.event",
|
||||
@@ -3272,6 +3280,7 @@
|
||||
"app.chain.search -> app.runtime",
|
||||
"app.chain.search -> app.runtime.config",
|
||||
"app.chain.search -> app.runtime.events",
|
||||
"app.chain.search -> app.runtime.execution",
|
||||
"app.chain.search -> app.runtime.log",
|
||||
"app.chain.search -> app.runtime.progress",
|
||||
"app.chain.search -> app.schemas",
|
||||
@@ -3966,6 +3975,7 @@
|
||||
"app.modules.acoustid -> app.adapters.network.http",
|
||||
"app.modules.acoustid -> app.modules",
|
||||
"app.modules.acoustid -> app.runtime",
|
||||
"app.modules.acoustid -> app.runtime.execution",
|
||||
"app.modules.acoustid -> app.runtime.log",
|
||||
"app.modules.acoustid -> app.runtime.settings",
|
||||
"app.modules.acoustid -> app.schemas",
|
||||
@@ -4054,6 +4064,7 @@
|
||||
"app.modules.discord.discord -> app.foundation",
|
||||
"app.modules.discord.discord -> app.foundation.size",
|
||||
"app.modules.discord.discord -> app.runtime",
|
||||
"app.modules.discord.discord -> app.runtime.execution",
|
||||
"app.modules.discord.discord -> app.runtime.log",
|
||||
"app.modules.discord.discord -> app.runtime.settings",
|
||||
"app.modules.discord.discord -> app.schemas",
|
||||
@@ -4589,6 +4600,7 @@
|
||||
"app.modules.indexer.spider -> app.foundation.temporal",
|
||||
"app.modules.indexer.spider -> app.foundation.url",
|
||||
"app.modules.indexer.spider -> app.runtime",
|
||||
"app.modules.indexer.spider -> app.runtime.execution",
|
||||
"app.modules.indexer.spider -> app.runtime.log",
|
||||
"app.modules.indexer.spider -> app.runtime.settings",
|
||||
"app.modules.indexer.spider -> app.schemas",
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
"""运行时同步 worker 的取消与容量合同回归。"""
|
||||
|
||||
import asyncio
|
||||
import ast
|
||||
import threading
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from anyio.to_thread import current_default_thread_limiter
|
||||
@@ -14,6 +16,31 @@ from app.runtime.execution import (
|
||||
)
|
||||
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def test_host_uses_canonical_threadpool_boundary() -> None:
|
||||
"""canonical 宿主不得重新直连框架线程池 helper。"""
|
||||
violations: list[str] = []
|
||||
for path in sorted((PROJECT_ROOT / "app").rglob("*.py")):
|
||||
relative_path = path.relative_to(PROJECT_ROOT).as_posix()
|
||||
if relative_path.startswith(
|
||||
("app/plugins/", "app/runtime/compat/", "app/sdk/", "app/testing/")
|
||||
):
|
||||
continue
|
||||
tree = ast.parse(path.read_text(encoding="utf-8-sig"), filename=str(path))
|
||||
for node in ast.walk(tree):
|
||||
if not isinstance(node, ast.ImportFrom) or node.module not in {
|
||||
"fastapi.concurrency",
|
||||
"starlette.concurrency",
|
||||
}:
|
||||
continue
|
||||
if any(alias.name == "run_in_threadpool" for alias in node.names):
|
||||
violations.append(f"{relative_path}:{node.lineno}")
|
||||
|
||||
assert violations == []
|
||||
|
||||
|
||||
def test_plugin_file_adapters_share_runtime_completion_contract() -> None:
|
||||
"""市场与插件包适配器不得各自维护另一套线程取消实现。"""
|
||||
assert market_adapter._await_thread_operation is run_in_threadpool_to_completion
|
||||
|
||||
Reference in New Issue
Block a user