mirror of
https://github.com/sartography/spiff-arena.git
synced 2025-01-13 11:05:56 +00:00
Refresh process_instance after obtaining the background lock (#189)
This commit is contained in:
parent
7b3eb4730f
commit
0640836b39
@ -25,7 +25,6 @@ from spiffworkflow_backend.models.process_instance_file_data import (
|
||||
from spiffworkflow_backend.models.process_model import ProcessModelInfo
|
||||
from spiffworkflow_backend.models.task import Task
|
||||
from spiffworkflow_backend.models.user import UserModel
|
||||
from spiffworkflow_backend.services.assertion_service import safe_assertion
|
||||
from spiffworkflow_backend.services.authorization_service import AuthorizationService
|
||||
from spiffworkflow_backend.services.git_service import GitCommandError
|
||||
from spiffworkflow_backend.services.git_service import GitService
|
||||
@ -96,13 +95,6 @@ class ProcessInstanceService:
|
||||
)
|
||||
process_instance_lock_prefix = "Background"
|
||||
for process_instance in records:
|
||||
with safe_assertion(process_instance.status == status_value) as false_assumption:
|
||||
if false_assumption:
|
||||
raise AssertionError(
|
||||
f"Queue assumed process instance {process_instance.id} has status of {status_value} "
|
||||
f"when it really is {process_instance.status}"
|
||||
)
|
||||
|
||||
locked = False
|
||||
processor = None
|
||||
try:
|
||||
@ -110,10 +102,12 @@ class ProcessInstanceService:
|
||||
processor = ProcessInstanceProcessor(process_instance)
|
||||
processor.lock_process_instance(process_instance_lock_prefix)
|
||||
locked = True
|
||||
execution_strategy_name = current_app.config[
|
||||
"SPIFFWORKFLOW_BACKEND_ENGINE_STEP_DEFAULT_STRATEGY_BACKGROUND"
|
||||
]
|
||||
processor.do_engine_steps(save=True, execution_strategy_name=execution_strategy_name)
|
||||
db.session.refresh(process_instance)
|
||||
if process_instance.status == status_value:
|
||||
execution_strategy_name = current_app.config[
|
||||
"SPIFFWORKFLOW_BACKEND_ENGINE_STEP_DEFAULT_STRATEGY_BACKGROUND"
|
||||
]
|
||||
processor.do_engine_steps(save=True, execution_strategy_name=execution_strategy_name)
|
||||
except ProcessInstanceIsAlreadyLockedError:
|
||||
continue
|
||||
except Exception as e:
|
||||
|
Loading…
x
Reference in New Issue
Block a user