Fix dictionary changed size during iteration error (#1711)

This commit is contained in:
jbirddog 2024-06-12 08:00:50 -04:00 committed by GitHub
parent 7536bc3716
commit 5659171fa3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,6 +5,7 @@ import time
from abc import abstractmethod from abc import abstractmethod
from collections.abc import Callable from collections.abc import Callable
from datetime import datetime from datetime import datetime
from threading import Lock
from typing import Any from typing import Any
from uuid import UUID from uuid import UUID
@ -15,6 +16,7 @@ from SpiffWorkflow.bpmn.exceptions import WorkflowTaskException # type: ignore
from SpiffWorkflow.bpmn.serializer.workflow import BpmnWorkflowSerializer # type: ignore from SpiffWorkflow.bpmn.serializer.workflow import BpmnWorkflowSerializer # type: ignore
from SpiffWorkflow.bpmn.specs.control import UnstructuredJoin # type: ignore from SpiffWorkflow.bpmn.specs.control import UnstructuredJoin # type: ignore
from SpiffWorkflow.bpmn.specs.event_definitions.message import MessageEventDefinition # type: ignore from SpiffWorkflow.bpmn.specs.event_definitions.message import MessageEventDefinition # type: ignore
from SpiffWorkflow.bpmn.specs.mixins import SubWorkflowTaskMixin # type: ignore
from SpiffWorkflow.bpmn.specs.mixins.events.event_types import CatchingEvent # type: ignore from SpiffWorkflow.bpmn.specs.mixins.events.event_types import CatchingEvent # type: ignore
from SpiffWorkflow.bpmn.workflow import BpmnWorkflow # type: ignore from SpiffWorkflow.bpmn.workflow import BpmnWorkflow # type: ignore
from SpiffWorkflow.exceptions import SpiffWorkflowException # type: ignore from SpiffWorkflow.exceptions import SpiffWorkflowException # type: ignore
@ -95,6 +97,8 @@ class EngineStepDelegate:
class ExecutionStrategy: class ExecutionStrategy:
"""Interface of sorts for a concrete execution strategy.""" """Interface of sorts for a concrete execution strategy."""
_mutex = Lock()
def __init__(self, delegate: EngineStepDelegate, options: dict | None = None): def __init__(self, delegate: EngineStepDelegate, options: dict | None = None):
self.delegate = delegate self.delegate = delegate
self.options = options self.options = options
@ -121,7 +125,15 @@ class ExecutionStrategy:
tld.process_model_identifier = process_model_identifier tld.process_model_identifier = process_model_identifier
g.user = user g.user = user
should_lock = any(isinstance(child.task_spec, SubWorkflowTaskMixin) for child in spiff_task.children)
if should_lock:
with self._mutex:
spiff_task.run() spiff_task.run()
else:
spiff_task.run()
return spiff_task return spiff_task
def spiff_run( def spiff_run(