Skip to content

Commit

Permalink
simplify subprocess state changes
Browse files Browse the repository at this point in the history
  • Loading branch information
essweine committed Apr 2, 2024
1 parent 25dafe9 commit c1150c6
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions SpiffWorkflow/bpmn/specs/mixins/subworkflow_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,12 @@ def _on_subworkflow_completed(self, subworkflow, my_task):
# could be used to run post-completed actions automatically.
# However, until I align the events with state transitions, I don't want to encourage external use of
# callback methods (though completed event is not going to change).
if my_task.state is TaskState.COMPLETED:
my_task._set_state(TaskState.READY)
my_task._set_state(TaskState.READY)

def _update_hook(self, my_task):
subprocess = my_task.workflow.top_workflow.subprocesses.get(my_task.id)
if subprocess is None:
super()._update_hook(my_task)
self.create_workflow(my_task)
self.start_workflow(my_task)
my_task._set_state(TaskState.STARTED)
else:
Expand All @@ -72,16 +70,12 @@ def copy_data(self, my_task, subworkflow):
def update_data(self, my_task, subworkflow):
my_task.data = deepcopy(subworkflow.last_task.data)

def create_workflow(self, my_task):
def start_workflow(self, my_task):
subworkflow = my_task.workflow.top_workflow.create_subprocess(my_task, self.spec)
subworkflow.completed_event.connect(self._on_subworkflow_completed, my_task)

def start_workflow(self, my_task):
subworkflow = my_task.workflow.top_workflow.get_subprocess(my_task)
self.copy_data(my_task, subworkflow)
start = subworkflow.get_next_task(spec_name='Start')
start.run()
my_task._set_state(TaskState.WAITING)


class CallActivity(SubWorkflowTask):
Expand Down

0 comments on commit c1150c6

Please sign in to comment.