ensure we save the process instance on error when in dequeue w/ burnettk

This commit is contained in:
jasquat 2023-04-12 11:16:39 -04:00
parent cafc7209a0
commit 78ea2b255a
3 changed files with 9 additions and 14 deletions

View File

@ -254,11 +254,7 @@ class GitService:
# build url for github page to open PR
git_remote = cls.run_shell_command_to_get_stdout(["git", "config", "--get", "remote.origin.url"])
git_remote = re.sub(
pattern=r'^git@([^:]+):',
repl='https://\\1/',
string=git_remote
)
git_remote = re.sub(pattern=r"^git@([^:]+):", repl="https://\\1/", string=git_remote)
remote_url = git_remote.strip().replace(".git", "")
pr_url = f"{remote_url}/compare/{branch_to_update}...{branch_to_pull_request}?expand=1"

View File

@ -419,15 +419,9 @@ 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."""
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
self.setup_processor_with_process_instance(
process_instance_model=process_instance_model, validate_only=validate_only
)
def setup_processor_with_process_instance(
self, process_instance_model: ProcessInstanceModel, validate_only: bool = False

View File

@ -96,6 +96,11 @@ class ProcessInstanceQueueService:
cls._dequeue(process_instance)
try:
yield
except Exception as ex:
process_instance.status = ProcessInstanceStatus.error.value
db.session.add(process_instance)
db.session.commit()
raise ex
finally:
if not reentering_lock:
cls._enqueue(process_instance)