Backoff Polling
BackoffPollingFlow runs PollingStep against an external service. When the condition is not met, the Step returns an expected error. Its ExecuteRetry policy retries that same execution with exponential backoff; a successful response completes the Flow.
Use RetryAfter to request the exact delay for the next retry while preserving the error. Because the expected not-ready result is a failed Step attempt, operation monitors and runbooks must classify it as expected and must not page on-call for it.
Core implementation
class PollingStep(Step[None]):
def get_step_options(self) -> StepOptions:
return StepOptions(
execute_retry=RetryPolicy(
initial_interval=timedelta(seconds=3),
backoff_coefficient=2.0,
maximum_attempts=5,
)
)
def execute(self, context: Context, input: None) -> StepDecision:
try:
result = self.service.attempt_external_api_call(
"Poll for BackoffPollingFlow"
)
except RuntimeError as error:
raise retry_after(1, error) from error
return graceful_complete(result)
Example: examples/python/dex_examples/patterns/polling/backoff_polling_flow.py