mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-04 23:17:20 +08:00
refactor: unify capability shutdown convergence
This commit is contained in:
@@ -247,8 +247,9 @@ class HostModuleAdapter:
|
||||
@staticmethod
|
||||
def stop(spec: CapabilitySpec, instance: Any, generation: int) -> None:
|
||||
"""停止实例拥有的资源;Runtime 会先撤销其运行态可见性。"""
|
||||
del spec, generation
|
||||
instance.stop()
|
||||
del generation
|
||||
if instance.stop() is False:
|
||||
raise RuntimeError(f"Host Module {spec.id} 资源未完成收口")
|
||||
|
||||
@staticmethod
|
||||
def cleanup(
|
||||
|
||||
@@ -224,13 +224,17 @@ class ModuleManager(metaclass=Singleton):
|
||||
self._refresh_running_projection()
|
||||
logger.info("所有模块停止完成")
|
||||
|
||||
def shutdown(self) -> None:
|
||||
"""进程关闭时不可逆停止 Runtime,阻止并发能力重新发布。"""
|
||||
def shutdown(self) -> bool:
|
||||
"""不可逆停止 Runtime,并返回所有模块 owner 是否收敛。"""
|
||||
logger.info("正在关闭模块运行时...")
|
||||
with self._lifecycle_lock:
|
||||
self._runtime.shutdown(reason="application_shutdown")
|
||||
converged = self._runtime.shutdown(reason="application_shutdown")
|
||||
self._refresh_running_projection()
|
||||
logger.info("模块运行时关闭完成")
|
||||
if converged:
|
||||
logger.info("模块运行时关闭完成")
|
||||
else:
|
||||
logger.error("模块运行时关闭后仍有资源 owner 未收敛")
|
||||
return converged
|
||||
|
||||
def reload(self) -> None:
|
||||
"""保留旧插件可观察的 stop、load、ModuleReload 同步顺序。"""
|
||||
|
||||
Reference in New Issue
Block a user