set process instance status to error if it cannot be initialized properly w/ burnettk

This commit is contained in:
jasquat 2023-04-07 14:13:04 -04:00
parent c491dd104b
commit 81de98176c
No known key found for this signature in database
2 changed files with 14 additions and 3 deletions

View File

@ -419,6 +419,20 @@ class ProcessInstanceProcessor:
# * __get_bpmn_process_instance, which takes spec and subprocesses and instantiates and returns a BpmnWorkflow
def __init__(self, process_instance_model: ProcessInstanceModel, validate_only: bool = False) -> None:
"""Create a Workflow Processor based on the serialized information available in the process_instance model."""
with ProcessInstanceQueueService.dequeued(process_instance_model):
try:
self.setup_processor_with_process_instance(
process_instance_model=process_instance_model, validate_only=validate_only
)
except Exception as ex:
process_instance_model.status = ProcessInstanceStatus.error.value
db.session.add(process_instance_model)
db.session.commit()
raise ex
def setup_processor_with_process_instance(
self, process_instance_model: ProcessInstanceModel, validate_only: bool = False
) -> None:
tld = current_app.config["THREAD_LOCAL_DATA"]
tld.process_instance_id = process_instance_model.id

View File

@ -131,9 +131,6 @@ class ProcessInstanceService:
continue
except Exception as e:
db.session.rollback() # in case the above left the database with a bad transaction
process_instance.status = ProcessInstanceStatus.error.value
db.session.add(process_instance)
db.session.commit()
error_message = (
f"Error running waiting task for process_instance {process_instance.id}"
+ f"({process_instance.process_model_identifier}). {str(e)}"