From 15355ea5e1fde8bd4c81c358a30753ebc6f8970c Mon Sep 17 00:00:00 2001 From: Mike Fedosin Date: Thu, 6 Jun 2019 15:46:34 +0200 Subject: [PATCH] Use get_task_executions_count for any_cancels method To get the result we need only a number of tasks, so there is no need to fetch full task executions from the database. Change-Id: I34ea985e6de08f46e1c40c64996357c8e6f3d79c --- mistral/workflow/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mistral/workflow/base.py b/mistral/workflow/base.py index 282ca298a..ca128a50d 100644 --- a/mistral/workflow/base.py +++ b/mistral/workflow/base.py @@ -202,7 +202,10 @@ class WorkflowController(object): :return: True if there is one or more tasks in cancelled state. """ - return len(self._get_task_executions(state=states.CANCELLED)) > 0 + return db_api.get_task_executions_count( + workflow_execution_id=self.wf_ex.id, + state=states.CANCELLED + ) > 0 @abc.abstractmethod def evaluate_workflow_final_context(self):