Skip to content

Step

Operation module: async_durable_execution._operation.step.

Use step() to checkpoint nondeterministic work and side effects. Completed steps return their saved result during replay instead of running again.

User-facing durable step operation.

Classes

StepInterruptedError

StepInterruptedError(
    message: str, step_id: str | None = None
)

Bases: InvocationError

Raised when a step is interrupted before it checkpointed at the end.

StepSemantics

Bases: Enum

Checkpoint timing guarantees for a durable step attempt.

StepContext dataclass

StepContext(
    execution_state: ExecutionState,
    operation_identifier: OperationIdentifier,
    attempt: int | None = None,
)

Bases: OperationContext

Context exposed while a step function is executing.

Functions:

step

step(
    func: Callable[[], Awaitable[T]],
    *,
    name: str | None = None,
    retry_strategy: Callable[
        [Exception, int], Duration | None
    ]
    | None = None,
    step_semantics: StepSemantics = AT_LEAST_ONCE_PER_RETRY,
    serdes: SerDes | None = None,
) -> Task[T]

Run user code as a checkpointed durable step.

Durable steps are the main way to isolate non-deterministic work such as API calls, clock reads, UUID generation, and database access from replayed code.

get_step_context

get_step_context() -> StepContext

Return the active StepContext.