From e445c483b044f1ad8ebac25c642fc09ec034ec29 Mon Sep 17 00:00:00 2001 From: DrSmoothl <1787882683@qq.com> Date: Fri, 13 Mar 2026 00:20:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E9=9D=9E=E9=98=BB?= =?UTF-8?q?=E5=A1=9E=20hook=20=E8=B6=85=E6=97=B6=E5=A4=84=E7=90=86?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=85=A8=E5=B1=80=E5=AE=89=E5=85=A8?= =?UTF-8?q?=E9=98=80=E6=94=AF=E6=8C=81=EF=BC=9B=E4=B8=BA=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20Supervisor=20=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=20IPC=20socket=20=E5=90=8E=E7=BC=80=E4=BB=A5=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugin_runtime/host/workflow_executor.py | 10 +++++----- src/plugin_runtime/integration.py | 10 +++++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/plugin_runtime/host/workflow_executor.py b/src/plugin_runtime/host/workflow_executor.py index e191eebb..ffc4e995 100644 --- a/src/plugin_runtime/host/workflow_executor.py +++ b/src/plugin_runtime/host/workflow_executor.py @@ -345,7 +345,8 @@ class WorkflowExecutor: ) -> None: """Non-blocking hook 调用,只读,忽略结果。""" timeout_ms = step.metadata.get("timeout_ms", 0) - timeout_sec = timeout_ms / 1000 if timeout_ms > 0 else None + # 使用 hook 声明的超时,但无声明时回退到全局安全阀,防止 task 泄漏 + timeout_sec = timeout_ms / 1000 if timeout_ms > 0 else _get_blocking_timeout() try: coro = invoke_fn(step.plugin_id, step.name, { @@ -354,10 +355,9 @@ class WorkflowExecutor: "message": message, "stage_outputs": ctx.stage_outputs, }) - if timeout_sec: - await asyncio.wait_for(coro, timeout=timeout_sec) - else: - await coro + await asyncio.wait_for(coro, timeout=timeout_sec) + except asyncio.TimeoutError: + logger.warning(f"[{ctx.trace_id}] non-blocking hook {step.full_name} 超时 ({timeout_sec}s)") except Exception as e: logger.debug(f"[{ctx.trace_id}] non-blocking hook {step.full_name}: {e}") diff --git a/src/plugin_runtime/integration.py b/src/plugin_runtime/integration.py index dcd04629..b306acb7 100644 --- a/src/plugin_runtime/integration.py +++ b/src/plugin_runtime/integration.py @@ -82,20 +82,24 @@ class PluginRuntimeManager: return # 从配置读取自定义 IPC socket 路径(留空则自动生成) - socket_path = _cfg.ipc_socket_path or None + socket_path_base = _cfg.ipc_socket_path or None + + # 当用户指定了自定义路径时,为两个 Supervisor 添加后缀以避免 UDS 冲突 + builtin_socket = f"{socket_path_base}-builtin" if socket_path_base else None + thirdparty_socket = f"{socket_path_base}-thirdparty" if socket_path_base else None # 创建两个 Supervisor,各自拥有独立的 socket / Runner 子进程 if builtin_dirs: self._builtin_supervisor = PluginSupervisor( plugin_dirs=builtin_dirs, - socket_path=socket_path, + socket_path=builtin_socket, ) self._register_capability_impls(self._builtin_supervisor) if thirdparty_dirs: self._thirdparty_supervisor = PluginSupervisor( plugin_dirs=thirdparty_dirs, - socket_path=socket_path, + socket_path=thirdparty_socket, ) self._register_capability_impls(self._thirdparty_supervisor)