예제 #1
0
 def run(self):
     with fasteners.try_lock(self._lock) as was_locked:
         if not was_locked:
             raise exc.ExecutionFailure("Engine currently locked, please"
                                        " try again later")
         for _state in self.run_iter():
             pass
예제 #2
0
    def run(self, timeout=None):
        """Runs the engine (or die trying).

        :param timeout: timeout to wait for any atoms to complete (this timeout
            will be used during the waiting period that occurs when
            unfinished atoms are being waited on).
        """
        with fasteners.try_lock(self._lock) as was_locked:
            if not was_locked:
                raise exc.ExecutionFailure("Engine currently locked, please"
                                           " try again later")
            for _state in self.run_iter(timeout=timeout):
                pass
예제 #3
0
    def _schedule_task(self, task):
        """Schedules the given task atom for *future* completion.

        Depending on the atoms stored intention this may schedule the task
        atom for reversion or execution.
        """
        intention = self._storage.get_atom_intention(task.name)
        if intention == st.EXECUTE:
            return self._task_action.schedule_execution(task)
        elif intention == st.REVERT:
            return self._task_action.schedule_reversion(task)
        else:
            raise excp.ExecutionFailure("Unknown how to schedule task with"
                                        " intention: %s" % intention)
예제 #4
0
    def _schedule_retry(self, retry):
        """Schedules the given retry atom for *future* completion.

        Depending on the atoms stored intention this may schedule the retry
        atom for reversion or execution.
        """
        intention = self._storage.get_atom_intention(retry.name)
        if intention == st.EXECUTE:
            return self._retry_action.execute(retry)
        elif intention == st.REVERT:
            return self._retry_action.revert(retry)
        elif intention == st.RETRY:
            self._retry_action.change_state(retry, st.RETRYING)
            _retry_subflow(retry, self._runtime)
            return self._retry_action.execute(retry)
        else:
            raise excp.ExecutionFailure("Unknown how to schedule retry with"
                                        " intention: %s" % intention)
예제 #5
0
    def schedule(self, retry):
        """Schedules the given retry atom for *future* completion.

        Depending on the atoms stored intention this may schedule the retry
        atom for reversion or execution.
        """
        intention = self._storage.get_atom_intention(retry.name)
        if intention == st.EXECUTE:
            return self._retry_action.schedule_execution(retry)
        elif intention == st.REVERT:
            return self._retry_action.schedule_reversion(retry)
        elif intention == st.RETRY:
            self._retry_action.change_state(retry, st.RETRYING)
            # This will force the subflow to start processing right *after*
            # this retry atom executes (since they will be blocked on their
            # predecessor getting out of the RETRYING/RUNNING state).
            self._runtime.retry_subflow(retry)
            return self._retry_action.schedule_execution(retry)
        else:
            raise excp.ExecutionFailure("Unknown how to schedule retry with"
                                        " intention: %s" % intention)
예제 #6
0
 def execute(self, **kwargs):
     raise exceptions.ExecutionFailure("We want to force a revert here")