From 7f7c9285d1dad3d38791da96d60748e8af37be14 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Tue, 1 Apr 2014 13:57:04 -0700 Subject: [PATCH] Avoid holding the state lock while notifying To avoid dead lock where a notifier will callback into the engine to perform a further state transition make sure we activate the state change notifiation after locking and not during it. Fixes bug 1301091 Change-Id: Ic81e15150e44d36489757372db32adfb5440feb4 --- taskflow/engines/action_engine/engine.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/taskflow/engines/action_engine/engine.py b/taskflow/engines/action_engine/engine.py index cd7acf95..4f3d85c1 100644 --- a/taskflow/engines/action_engine/engine.py +++ b/taskflow/engines/action_engine/engine.py @@ -110,17 +110,18 @@ class ActionEngine(base.EngineBase): failures = self.storage.get_failures() misc.Failure.reraise_if_any(failures.values()) - @lock_utils.locked(lock='_state_lock') def _change_state(self, state): - old_state = self.storage.get_flow_state() - if not states.check_flow_transition(old_state, state): - return - self.storage.set_flow_state(state) + with self._state_lock: + old_state = self.storage.get_flow_state() + if not states.check_flow_transition(old_state, state): + return + self.storage.set_flow_state(state) try: flow_uuid = self._flow.uuid except AttributeError: - # NOTE(harlowja): if the flow was just a single task, then it will - # not itself have a uuid, but the constructed flow_detail will. + # NOTE(harlowja): if the flow was just a single task, then it + # will not itself have a uuid, but the constructed flow_detail + # will. if self._flow_detail is not None: flow_uuid = self._flow_detail.uuid else: