refactor: unify plugin file operation cancellation

This commit is contained in:
jxxghp
2026-08-24 03:17:07 +08:00
parent e768eb46fe
commit 10582277e2
7 changed files with 38 additions and 35 deletions
+11
View File
@@ -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:
"""调用方取消后,执行令牌必须由真实同步调用持有到终态。"""