From 33964a08bb96079af9ce12d4f05e4e9dc58dba3f Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 10 Apr 2023 16:34:52 -0400 Subject: [PATCH] remove predicted children when processing the parent instead of when processing the children w/ burnettk --- .../services/workflow_execution_service.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/workflow_execution_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/workflow_execution_service.py index d0f73eab..4f3fba38 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/workflow_execution_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/workflow_execution_service.py @@ -1,3 +1,4 @@ +import copy import time from typing import Callable from typing import Optional @@ -138,9 +139,16 @@ class TaskModelSavingDelegate(EngineStepDelegate): | TaskState.LIKELY | TaskState.FUTURE ): + # these will be removed from the parent and then ignored if waiting_spiff_task._has_state(TaskState.PREDICTED_MASK): - TaskService.remove_spiff_task_from_parent(waiting_spiff_task, self.task_service.task_models) continue + + # removing elements from an array causes the loop to exit so deep copy the array first + waiting_children = copy.copy(waiting_spiff_task.children) + for waiting_child in waiting_children: + if waiting_child._has_state(TaskState.PREDICTED_MASK): + waiting_spiff_task.children.remove(waiting_child) + self.task_service.update_task_model_with_spiff_task(waiting_spiff_task) # # NOTE: process-spiff-tasks-list: this would be the ideal way to handle all tasks