Exemple #1
0
    def update(self, state):
        assert self.action_ex

        if state == states.PAUSED and self.is_sync(self.action_ex.input):
            raise exc.InvalidStateTransitionException(
                'Transition to the PAUSED state is only supported '
                'for asynchronous action execution.')

        if not states.is_valid_transition(self.action_ex.state, state):
            raise exc.InvalidStateTransitionException(
                'Invalid state transition from %s to %s.' %
                (self.action_ex.state, state))

        self.action_ex.state = state
Exemple #2
0
    def update(self, state):
        assert self.action_ex

        # TODO(rakhmerov): Not sure we can do it for all actions.
        action = self.action_desc.instantiate(self.action_ex.input, {})

        if state == states.PAUSED and action.is_sync():
            raise exc.InvalidStateTransitionException(
                'Transition to the PAUSED state is only supported '
                'for asynchronous action execution.')

        if not states.is_valid_transition(self.action_ex.state, state):
            raise exc.InvalidStateTransitionException(
                'Invalid state transition from %s to %s.' %
                (self.action_ex.state, state))

        self.action_ex.state = state