Skip to content

Wait for Condition

Internal implementation module: async_durable_execution._operation.wait_for_condition.

Use wait_for_condition() to checkpoint polling state between deterministic condition checks.

Implement the durable wait_for_condition operation.

Classes

WaitForConditionError

WaitForConditionError(
    message: str,
    termination_reason: TerminationReason = EXECUTION_ERROR,
)

Bases: ExecutionError

Raised when a wait_for_condition operation exhausts its attempts.

PollingStrategy dataclass

PollingStrategy(
    max_attempts: int = 6,
    initial_delay: Duration = 5,
    max_delay: Duration = 60,
    backoff_rate: int | float = 2,
    jitter_strategy: JitterStrategy = FULL,
    increment: Duration | None = None,
)

Bases: _DelayStrategy, Generic[T]

Polling strategy for wait_for_condition().

WaitForConditionCheckContext dataclass

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

Bases: StepContext

Context available during wait_for_condition checker execution.

Functions:

wait_for_condition

wait_for_condition(
    check: Callable[[T | None], Awaitable[T]],
    *,
    initial_state: T | None = None,
    name: str | None = None,
    polling_strategy: PollingStrategyFunction[T]
    | None = None,
    serdes: SerDes | None = None,
) -> Task[T]

Poll durable state until the configured strategy decides to stop waiting.

The check receives the current state, beginning with initial_state, and returns the next state. The polling strategy receives that result and returns the next polling delay, or None to stop polling and complete with the latest result.

get_wait_for_condition_check_context

get_wait_for_condition_check_context() -> (
    WaitForConditionCheckContext
)

Return the active WaitForConditionCheckContext.