From 526f6321d178c5a6c23ced89ba02bdd9d69688e1 Mon Sep 17 00:00:00 2001 From: "Guowen.Bao" Date: Fri, 28 Feb 2025 15:39:17 +0800 Subject: [PATCH] fix: resolved the issue of not releasing ThreadPoolExecutor when an exception occurs in _generate_worker Signed-off-by: Guowen.Bao --- api/core/workflow/graph_engine/graph_engine.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/core/workflow/graph_engine/graph_engine.py b/api/core/workflow/graph_engine/graph_engine.py index 937f4a2a59..acdd8562ff 100644 --- a/api/core/workflow/graph_engine/graph_engine.py +++ b/api/core/workflow/graph_engine/graph_engine.py @@ -169,6 +169,7 @@ class GraphEngine: error=item.route_node_state.failed_reason or "Unknown error.", exceptions_count=len(handle_exceptions), ) + self._release_thread() return elif isinstance(item, NodeRunSucceededEvent): if item.node_type == NodeType.END: @@ -195,6 +196,7 @@ class GraphEngine: except Exception as e: logger.exception("Graph run failed") yield GraphRunFailedEvent(error=str(e), exceptions_count=len(handle_exceptions)) + self._release_thread() return # count exceptions to determine partial success if len(handle_exceptions) > 0: