mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-11-01 04:47:03 +08:00
fix(plugin-market): satisfy index request type gate
This commit is contained in:
25
app/adapters/external/plugin/client.py
vendored
25
app/adapters/external/plugin/client.py
vendored
@@ -1161,7 +1161,7 @@ class PluginMarketTransport(metaclass=WeakSingleton):
|
||||
def _remove_index_task(
|
||||
cls,
|
||||
key: tuple[asyncio.AbstractEventLoop, str, str],
|
||||
task: asyncio.Task[Optional[PluginIndex]],
|
||||
task: asyncio.Future[Optional[PluginIndex]],
|
||||
) -> None:
|
||||
"""异步索引请求结束后释放事件循环和仓库引用。"""
|
||||
with cls._index_task_lock:
|
||||
@@ -1223,10 +1223,14 @@ class PluginMarketTransport(metaclass=WeakSingleton):
|
||||
key = self._plugin_index_key(repo_url, package_version)
|
||||
with self._index_future_lock:
|
||||
future = self._index_futures.get(key)
|
||||
owner = future is None
|
||||
if owner:
|
||||
future = Future()
|
||||
if future is None:
|
||||
future = Future[Optional[PluginIndex]]()
|
||||
self._index_futures[key] = future
|
||||
owner = True
|
||||
else:
|
||||
owner = False
|
||||
|
||||
assert future is not None
|
||||
|
||||
if not owner:
|
||||
return future.result()
|
||||
@@ -1592,12 +1596,13 @@ class PluginMarketTransport(metaclass=WeakSingleton):
|
||||
),
|
||||
)
|
||||
self._index_tasks[task_key] = task
|
||||
task.add_done_callback(
|
||||
lambda completed_task, key=task_key: self._remove_index_task(
|
||||
key,
|
||||
completed_task,
|
||||
)
|
||||
)
|
||||
|
||||
def on_index_task_done(
|
||||
completed_task: asyncio.Future[Optional[PluginIndex]],
|
||||
) -> None:
|
||||
self._remove_index_task(task_key, completed_task)
|
||||
|
||||
task.add_done_callback(on_index_task_done)
|
||||
|
||||
# 单个调用方取消等待时不能连带取消共享请求。
|
||||
return await asyncio.shield(task)
|
||||
|
||||
Reference in New Issue
Block a user