plumpy.process_states module#

class plumpy.process_states.Continue(continue_fn: Callable[[...], Any], *args: Any, **kwargs: Any)[source]#

Bases: Command

CONTINUE_FN = 'continue_fn'#
_auto_persist: Set[str] | None = {'args', 'kwargs'}#
load_instance_state(saved_state: MutableMapping[str, Any], load_context: LoadSaveContext) None[source]#
save_instance_state(out_state: MutableMapping[str, Any], save_context: LoadSaveContext) None[source]#
class plumpy.process_states.Created(process: Process, run_fn: Callable[..., Any], *args: Any, **kwargs: Any)[source]#

Bases: State

ALLOWED: Set[LABEL_TYPE] = {ProcessState.EXCEPTED, ProcessState.KILLED, ProcessState.RUNNING}#
LABEL: LABEL_TYPE = 'created'#
RUN_FN = 'run_fn'#
_auto_persist: Set[str] | None = {'args', 'in_state', 'kwargs'}#
execute() State[source]#

Execute the state, performing the actions that this state is responsible for. :returns: a state to transition to or None if finished.

in_state: bool#
load_instance_state(saved_state: MutableMapping[str, Any], load_context: LoadSaveContext) None[source]#
save_instance_state(out_state: MutableMapping[str, Any], save_context: LoadSaveContext) None[source]#
class plumpy.process_states.Excepted(process: Process, exception: BaseException | None, trace_back: TracebackType | None = None)[source]#

Bases: State

Excepted state, can optionally provide exception and trace_back

Parameters:
  • exception – The exception instance

  • trace_back – An optional exception traceback

EXC_VALUE = 'ex_value'#
LABEL: LABEL_TYPE = 'excepted'#
TRACEBACK = 'traceback'#
get_exc_info() Tuple[Type[BaseException] | None, BaseException | None, TracebackType | None][source]#

Recreate the exc_info tuple and return it

in_state: bool#
load_instance_state(saved_state: MutableMapping[str, Any], load_context: LoadSaveContext) None[source]#
save_instance_state(out_state: MutableMapping[str, Any], save_context: LoadSaveContext) None[source]#
class plumpy.process_states.Finished(process: Process, result: Any, successful: bool)[source]#

Bases: State

State for process is finished.

Parameters:
  • result – The result of process

  • successful – Boolean for the exit code is 0 the process is successful.

LABEL: LABEL_TYPE = 'finished'#
_auto_persist: Set[str] | None = {'in_state', 'result', 'successful'}#
in_state: bool#
exception plumpy.process_states.Interruption[source]#

Bases: Exception

class plumpy.process_states.Kill(msg: Dict[str, Any] | None = None)[source]#

Bases: Command

_auto_persist: Set[str] | None = {'msg'}#
exception plumpy.process_states.KillInterruption(msg_text: str | None, force_kill: bool = False)[source]#

Bases: Interruption

class plumpy.process_states.Killed(process: Process, msg: MessageType | None)[source]#

Bases: State

Represents a state where a process has been killed.

This state is used to indicate that a process has been terminated and can optionally include a message providing details about the termination.

Parameters:

msg – An optional message explaining the reason for the process termination.

LABEL: LABEL_TYPE = 'killed'#
_auto_persist: Set[str] | None = {'in_state', 'msg'}#
in_state: bool#
exception plumpy.process_states.PauseInterruption(msg_text: str | None)[source]#

Bases: Interruption

class plumpy.process_states.ProcessState(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: Enum

The possible states that a Process can be in.

CREATED = 'created'#
EXCEPTED = 'excepted'#
FINISHED = 'finished'#
KILLED = 'killed'#
RUNNING = 'running'#
WAITING = 'waiting'#
class plumpy.process_states.Running(process: Process, run_fn: Callable[..., Awaitable[Any] | Any], *args: Any, **kwargs: Any)[source]#

Bases: State

ALLOWED: Set[LABEL_TYPE] = {ProcessState.EXCEPTED, ProcessState.FINISHED, ProcessState.KILLED, ProcessState.RUNNING, ProcessState.WAITING}#
COMMAND = 'command'#
LABEL: LABEL_TYPE = 'running'#
RUN_FN = 'run_fn'#
_action_command(command: Kill | Stop | Wait | Continue) State[source]#
_auto_persist: Set[str] | None = {'args', 'in_state', 'kwargs'}#
_command: None | Kill | Stop | Wait | Continue = None#
_run_handle = None#
_running: bool = False#
async execute() State[source]#

Execute the state, performing the actions that this state is responsible for. :returns: a state to transition to or None if finished.

in_state: bool#
interrupt(reason: Any) None[source]#
load_instance_state(saved_state: MutableMapping[str, Any], load_context: LoadSaveContext) None[source]#
save_instance_state(out_state: MutableMapping[str, Any], save_context: LoadSaveContext) None[source]#
class plumpy.process_states.Stop(result: Any, successful: bool)[source]#

Bases: Command

_auto_persist: Set[str] | None = {'result'}#
class plumpy.process_states.Wait(continue_fn: Callable[[...], Any] | None = None, msg: Any | None = None, data: Any | None = None)[source]#

Bases: Command

_auto_persist: Set[str] | None = {'data', 'msg'}#
class plumpy.process_states.Waiting(process: Process, done_callback: Callable[..., Any] | None, msg: str | None = None, data: Any | None = None)[source]#

Bases: State

ALLOWED: Set[LABEL_TYPE] = {ProcessState.EXCEPTED, ProcessState.FINISHED, ProcessState.KILLED, ProcessState.RUNNING, ProcessState.WAITING}#
DONE_CALLBACK = 'DONE_CALLBACK'#
LABEL: LABEL_TYPE = 'waiting'#
_auto_persist: Set[str] | None = {'data', 'in_state', 'msg'}#
_interruption = None#
_waiting_future: futures.Future#
async execute() State[source]#

Execute the state, performing the actions that this state is responsible for. :returns: a state to transition to or None if finished.

in_state: bool#
interrupt(reason: Any) None[source]#
load_instance_state(saved_state: MutableMapping[str, Any], load_context: LoadSaveContext) None[source]#
resume(value: ~typing.Any = <plumpy.lang.__NULL object>) None[source]#
save_instance_state(out_state: MutableMapping[str, Any], save_context: LoadSaveContext) None[source]#