WaitFor Failure Recovery
Recover after WaitFor exhausts its retry policy.
WaitForFailureRecoveryFlow starts FailingStep. Its WaitFor method returns the interval to wait on, but the sample deliberately fails that method. After WaitForRetry is exhausted, its WaitForFailure policy proceeds to FailingStep.Execute. Execute reads the wait failure from its context, then moves to RecoveryStep, which completes the Flow.
Use this pattern when a failed condition lookup is recoverable and the Flow can decide what to do in normal Step code.
Core implementation
WaitForFailure must be set to proceed after a bounded WaitForRetry policy. That makes Dex call FailingStep.Execute with the failure recorded in the context. The Step checks that state, then moves to RecoveryStep.
class FailingStep(Step[str]):
def get_step_options(self) -> StepOptions:
return StepOptions(
wait_for_retry=RetryPolicy(maximum_attempts=2),
wait_for_failure=WaitForFailurePolicy.PROCEED,
)
def wait_for(self, context: Context, input: str) -> Wait:
raise RuntimeError("planned WaitFor failure")
def execute(self, context: Context, input: str) -> StepDecision:
if not context.wait_for_method_failed():
raise RuntimeError("waitFor failure was not reported")
return go_to(RecoveryStep, input)
class RecoveryStep(Step[str]):
def execute(self, context: Context, input: str) -> StepDecision:
return graceful_complete(f"recovered {input}")
Example: examples/python/dex_examples/primitives/proceed_on_wait_failure/proceed_on_wait_failure_flow.py