mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-04 23:17:20 +08:00
refactor: unify plugin file operation cancellation
This commit is contained in:
+4
-2
@@ -13,8 +13,8 @@
|
||||
"runtime_to_db": [],
|
||||
"workflow_to_db": []
|
||||
},
|
||||
"edge_count": 6529,
|
||||
"edge_sha256": "daf8459c6194e28766d62c5f16a0e1bb64caf3f3430f51736b57da505e4401e1",
|
||||
"edge_count": 6531,
|
||||
"edge_sha256": "86b2ad0b585deba78c5e0e5e7e4b55cd66e05a2d5e988ed28ac7f6a4ae15ff2f",
|
||||
"edges": [
|
||||
"app -> app.runtime",
|
||||
"app -> app.runtime.compat",
|
||||
@@ -62,6 +62,7 @@
|
||||
"app.adapters.external.market -> app.foundation.version",
|
||||
"app.adapters.external.market -> app.runtime",
|
||||
"app.adapters.external.market -> app.runtime.cache",
|
||||
"app.adapters.external.market -> app.runtime.execution",
|
||||
"app.adapters.external.market -> app.runtime.log",
|
||||
"app.adapters.external.market -> app.runtime.observability",
|
||||
"app.adapters.external.market -> app.runtime.settings",
|
||||
@@ -145,6 +146,7 @@
|
||||
"app.adapters.system.plugin.package -> app.adapters.external",
|
||||
"app.adapters.system.plugin.package -> app.adapters.external.market",
|
||||
"app.adapters.system.plugin.package -> app.runtime",
|
||||
"app.adapters.system.plugin.package -> app.runtime.execution",
|
||||
"app.adapters.system.plugin.package -> app.runtime.log",
|
||||
"app.adapters.system.plugin.package -> app.runtime.settings",
|
||||
"app.adapters.system.resource -> app.adapters",
|
||||
|
||||
@@ -196,7 +196,10 @@ def _patch_async_remote_install(helper, monkeypatch, meta: dict,
|
||||
monkeypatch.setattr(helper, "_PluginHelper__async_install_dependencies_if_required", fake_dependencies)
|
||||
monkeypatch.setattr(helper, "_PluginHelper__async_install_from_release", fake_release)
|
||||
monkeypatch.setattr(helper, "_PluginHelper__prepare_content_via_filelist_async", fake_filelist)
|
||||
monkeypatch.setattr("app.adapters.external.market.asyncio.to_thread", fake_to_thread)
|
||||
monkeypatch.setattr(
|
||||
"app.adapters.external.market._await_thread_operation",
|
||||
fake_to_thread,
|
||||
)
|
||||
return calls
|
||||
|
||||
|
||||
|
||||
@@ -6,9 +6,20 @@ import threading
|
||||
import pytest
|
||||
from anyio.to_thread import current_default_thread_limiter
|
||||
|
||||
from app.adapters.external import market as market_adapter
|
||||
from app.adapters.system.plugin import package as plugin_package_adapter
|
||||
from app.runtime.execution import run_in_threadpool_to_completion
|
||||
|
||||
|
||||
def test_plugin_file_adapters_share_runtime_completion_contract() -> None:
|
||||
"""市场与插件包适配器不得各自维护另一套线程取消实现。"""
|
||||
assert market_adapter._await_thread_operation is run_in_threadpool_to_completion
|
||||
assert (
|
||||
plugin_package_adapter._await_thread_operation
|
||||
is run_in_threadpool_to_completion
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_threadpool_capacity_is_held_until_cancelled_call_finishes() -> None:
|
||||
"""调用方取消后,执行令牌必须由真实同步调用持有到终态。"""
|
||||
|
||||
Reference in New Issue
Block a user