Skip to content

Commit

Permalink
fix(workflow): "Max submit count reached" error occurred when executi…
Browse files Browse the repository at this point in the history
…ng workflow as tool in iteration (#8595)
  • Loading branch information
takatost authored Sep 20, 2024
1 parent 7f3282e commit e0a3307
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions api/core/workflow/graph_engine/graph_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,20 @@ def run(self) -> Generator[GraphEngineEvent, None, None]:

# trigger graph run success event
yield GraphRunSucceededEvent(outputs=self.graph_runtime_state.outputs)
self._release_thread()
except GraphRunFailedError as e:
yield GraphRunFailedEvent(error=e.error)
self._release_thread()
return
except Exception as e:
logger.exception("Unknown Error when graph running")
yield GraphRunFailedEvent(error=str(e))
self._release_thread()
raise e
finally:
if self.is_main_thread_pool and self.thread_pool_id in GraphEngine.workflow_thread_pool_mapping:
del GraphEngine.workflow_thread_pool_mapping[self.thread_pool_id]

def _release_thread(self):
if self.is_main_thread_pool and self.thread_pool_id in GraphEngine.workflow_thread_pool_mapping:
del GraphEngine.workflow_thread_pool_mapping[self.thread_pool_id]

def _run(
self,
Expand Down
1 change: 1 addition & 0 deletions api/core/workflow/nodes/iteration/iteration_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def _run(self) -> Generator[RunEvent | InNodeEvent, None, None]:
variable_pool=variable_pool,
max_execution_steps=dify_config.WORKFLOW_MAX_EXECUTION_STEPS,
max_execution_time=dify_config.WORKFLOW_MAX_EXECUTION_TIME,
thread_pool_id=self.thread_pool_id,
)

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

0 comments on commit e0a3307

Please sign in to comment.