plumpy.base package#
- class plumpy.base.StateMachine(*args: Any, **kwargs: Any)[source]#
Bases:
object- _transition_failing = False#
- _transitioning = False#
- add_state_event_callback(hook: Hashable, callback: Callable[[StateMachine, Hashable, State | None], None]) None[source]#
Add a callback to be called on a particular state event hook. The callback should have form fn(state_machine, hook, state)
- Parameters:
hook – The state event hook
callback – The callback function
- remove_state_event_callback(hook: Hashable, callback: Callable[[StateMachine, Hashable, State | None], None]) None[source]#
- transition_failed(initial_state: Hashable, final_state: Hashable, exception: Exception, trace: TracebackType) None[source]#
Called when a state transitions fails.
This method can be overwritten to change the default behaviour which is to raise the exception.
- Parameters:
exception – The transition failed exception.
- transition_to(new_state: State | None, **kwargs: Any) None[source]#
Transite to the new state.
The new target state will be create lazily when the state is not yet instantiated, which will happened for states not in the expect path such as pause and kill. The arguments are passed to the state class to create state instance. (process arg does not need to pass since it will always call with ‘self’ as process)
- exception plumpy.base.TransitionFailed(initial_state: State, final_state: State | None = None, traceback_str: str | None = None)[source]#
Bases:
ExceptionA state transition failed
- plumpy.base.call_with_super_check(wrapped: Callable[[...], Any], *args: Any, **kwargs: Any) None[source]#
Call a class method checking that all subclasses called super along the way
- plumpy.base.event(from_states: str | Type[State] | Iterable[Type[State]] = '*', to_states: str | Type[State] | Iterable[Type[State]] = '*') Callable[[Callable[[...], Any]], Callable[[...], Any]][source]#
A decorator to check for correct transitions, raising
EventErroron invalid transitions.
- plumpy.base.super_check(wrapped: Callable[[...], Any]) Callable[[...], Any][source]#
Decorator to add a super check to a function to be used with call_with_super_check
Submodules#
- plumpy.base.state_machine module
StateMachineStateMachine.STATESStateMachine._STATES_MAPStateMachine.__ensure_built()StateMachine._create_state_instance()StateMachine._enter_next_state()StateMachine._event_callbacksStateMachine._exit_current_state()StateMachine._fire_state_event()StateMachine._stateStateMachine._transition_failingStateMachine._transitioningStateMachine.add_state_event_callback()StateMachine.create_initial_state()StateMachine.create_state()StateMachine.get_debug()StateMachine.get_state_class()StateMachine.get_states()StateMachine.get_states_map()StateMachine.init()StateMachine.initial_state_label()StateMachine.on_terminated()StateMachine.remove_state_event_callback()StateMachine.set_debug()StateMachine.stateStateMachine.transition_failed()StateMachine.transition_to()
StateMachineMetaTransitionFailedevent()
- plumpy.base.utils module