class LoggingBase( deprecation.moved_inheritable_class(DumpingListener, 'LoggingBase', __name__, version="0.6", removal_version="?")): def _dump(self, message, *args, **kwargs): self._log(message, *args, **kwargs) @abc.abstractmethod def _log(self, message, *args, **kwargs): """Logs the provided *templated* message to some output."""
def prepare(self): """Performs any pre-run, but post-compilation actions. NOTE(harlowja): During preparation it is currently assumed that the underlying storage will be initialized, all final dependencies will be verified, the tasks will be reset and the engine will enter the PENDING state. """ @abc.abstractmethod def run(self): """Runs the flow in the engine to completion (or die trying).""" @abc.abstractmethod def suspend(self): """Attempts to suspend the engine. If the engine is currently running tasks then this will attempt to suspend future work from being started (currently active tasks can not currently be preempted) and move the engine into a suspend state which can then later be resumed from. """ # TODO(harlowja): remove in 0.7 or later... EngineBase = deprecation.moved_inheritable_class(Engine, 'EngineBase', __name__, version="0.6", removal_version="?")
@abc.abstractmethod def prepare(self): """Performs any pre-run, but post-compilation actions. NOTE(harlowja): During preparation it is currently assumed that the underlying storage will be initialized, all final dependencies will be verified, the tasks will be reset and the engine will enter the PENDING state. """ @abc.abstractmethod def run(self): """Runs the flow in the engine to completion (or die trying).""" @abc.abstractmethod def suspend(self): """Attempts to suspend the engine. If the engine is currently running tasks then this will attempt to suspend future work from being started (currently active tasks can not currently be preempted) and move the engine into a suspend state which can then later be resumed from. """ # TODO(harlowja): remove in 0.7 or later... EngineBase = deprecation.moved_inheritable_class(Engine, 'EngineBase', __name__, version="0.6", removal_version="?")
return self def __exit__(self, type, value, tb): try: self.deregister() except Exception: # Don't let deregistering throw exceptions LOG.warn("Failed deregistering listeners from engine %s", self._engine, exc_info=True) # TODO(harlowja): remove in 0.7 or later... ListenerBase = deprecation.moved_inheritable_class(Listener, 'ListenerBase', __name__, version="0.6", removal_version="?") @six.add_metaclass(abc.ABCMeta) class DumpingListener(Listener): """Abstract base class for dumping listeners. This provides a simple listener that can be attached to an engine which can be derived from to dump task and/or flow state transitions to some target backend. To implement your own dumping listener derive from this class and override the ``_dump`` method. """
def __enter__(self): self.register() return self def __exit__(self, type, value, tb): try: self.deregister() except Exception: # Don't let deregistering throw exceptions LOG.warn("Failed deregistering listeners from engine %s", self._engine, exc_info=True) # TODO(harlowja): remove in 0.7 or later... ListenerBase = deprecation.moved_inheritable_class(Listener, 'ListenerBase', __name__, version="0.6", removal_version="?") @six.add_metaclass(abc.ABCMeta) class DumpingListener(Listener): """Abstract base class for dumping listeners. This provides a simple listener that can be attached to an engine which can be derived from to dump task and/or flow state transitions to some target backend. To implement your own dumping listener derive from this class and override the ``_dump`` method. """