Skip to content

Commit e0a3307

Browse files
authored
fix(workflow): "Max submit count reached" error occurred when executing workflow as tool in iteration (langgenius#8595)
1 parent 7f3282e commit e0a3307

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

api/core/workflow/graph_engine/graph_engine.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,20 @@ def run(self) -> Generator[GraphEngineEvent, None, None]:
180180

181181
# trigger graph run success event
182182
yield GraphRunSucceededEvent(outputs=self.graph_runtime_state.outputs)
183+
self._release_thread()
183184
except GraphRunFailedError as e:
184185
yield GraphRunFailedEvent(error=e.error)
186+
self._release_thread()
185187
return
186188
except Exception as e:
187189
logger.exception("Unknown Error when graph running")
188190
yield GraphRunFailedEvent(error=str(e))
191+
self._release_thread()
189192
raise e
190-
finally:
191-
if self.is_main_thread_pool and self.thread_pool_id in GraphEngine.workflow_thread_pool_mapping:
192-
del GraphEngine.workflow_thread_pool_mapping[self.thread_pool_id]
193+
194+
def _release_thread(self):
195+
if self.is_main_thread_pool and self.thread_pool_id in GraphEngine.workflow_thread_pool_mapping:
196+
del GraphEngine.workflow_thread_pool_mapping[self.thread_pool_id]
193197

194198
def _run(
195199
self,

api/core/workflow/nodes/iteration/iteration_node.py

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def _run(self) -> Generator[RunEvent | InNodeEvent, None, None]:
8989
variable_pool=variable_pool,
9090
max_execution_steps=dify_config.WORKFLOW_MAX_EXECUTION_STEPS,
9191
max_execution_time=dify_config.WORKFLOW_MAX_EXECUTION_TIME,
92+
thread_pool_id=self.thread_pool_id,
9293
)
9394

9495
start_at = datetime.now(timezone.utc).replace(tzinfo=None)

0 commit comments

Comments
 (0)