Allow terminating not_started instances (#329)

* Support terminating instances that have not started

* Getting ./bin/pyl to pass
This commit is contained in:
jbirddog 2023-06-12 16:41:08 -04:00 committed by GitHub
parent a97d94f2e1
commit d1581d94d4
2 changed files with 8 additions and 1 deletions

View File

@ -370,6 +370,8 @@ def _interstitial_stream(process_instance: ProcessInstanceModel) -> Generator[st
def render_instructions(spiff_task: SpiffTask) -> str:
task_model = TaskModel.query.filter_by(guid=str(spiff_task.id)).first()
if task_model is None:
return ""
extensions = TaskService.get_extensions_from_task_model(task_model)
return _render_instructions_for_end_user(task_model, extensions)

View File

@ -8,6 +8,7 @@ import re
import time
import uuid
from collections.abc import Callable
from contextlib import suppress
from datetime import datetime
from datetime import timedelta
from hashlib import sha256
@ -1643,7 +1644,7 @@ class ProcessInstanceProcessor:
return task
return None
def terminate(self) -> None:
def remove_spiff_tasks_for_termination(self) -> None:
start_time = time.time()
deleted_tasks = self.bpmn_process_instance.cancel() or []
spiff_tasks = self.bpmn_process_instance.get_tasks()
@ -1670,6 +1671,10 @@ class ProcessInstanceProcessor:
db.session.delete(task)
self.save()
def terminate(self) -> None:
with suppress(KeyError):
self.remove_spiff_tasks_for_termination()
self.process_instance_model.status = "terminated"
db.session.add(self.process_instance_model)
ProcessInstanceTmpService.add_event_to_process_instance(