commit the db at the end of the save method in the processor to avoid race conditions between process instance and human task w/ burnettk (#1158)

Co-authored-by: jasquat <jasquat@users.noreply.github.com>
This commit is contained in:
jasquat 2024-03-04 14:27:27 -05:00 committed by GitHub
parent a71af6e40f
commit 4cebddb6c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 4 deletions

View File

@ -1072,7 +1072,6 @@ class ProcessInstanceProcessor:
self._workflow_completed_handler(self.process_instance_model)
db.session.add(self.process_instance_model)
db.session.commit()
human_tasks = HumanTaskModel.query.filter_by(process_instance_id=self.process_instance_model.id, completed=False).all()
ready_or_waiting_tasks = self.get_all_ready_or_waiting_tasks()
@ -1136,13 +1135,11 @@ class ProcessInstanceProcessor:
human_task_user = HumanTaskUserModel(user_id=potential_owner_id, human_task=human_task)
db.session.add(human_task_user)
db.session.commit()
if len(human_tasks) > 0:
for at in human_tasks:
at.completed = True
db.session.add(at)
db.session.commit()
db.session.commit()
def serialize_task_spec(self, task_spec: SpiffTask) -> dict:
"""Get a serialized version of a task spec."""