Skip to main content

Set the number of retries

To rerun your workflow when an exception is raised, set the retries parameter to an integer.

Wait between retries

To add a wait between retries, pass a value to the retry_delay_seconds parameter.

Retry parts of a workflow

You can configure retries for individual tasks in a workflow to limit the scope of a retry.

Retry with configurable delay

A task’s retry delays can also be defined as a list of integers for different delays between retries.
You can also use the exponential_backoff utility to generate a list of retry delays that correspond to an exponential backoff retry strategy.

Retry with a custom condition

Whether or not a task should be retried can be determined dynamically by passing a callable to the retry_condition_fn parameter.
If a callable passed to retry_condition_fn returns True, the task will be retried. Otherwise, the task will exit with an exception.

Add jitter to retry delays

To add a random amount of time to retry delays, pass a value to the retry_jitter_factor parameter.
Adding jitter to the retry delays avoids multiple tasks introducing load to external systems by failing and retrying at the exact same cadence.

Configure task retry behavior globally

You can set the default retries and retry delays for all tasks via Prefect’s settings. The default values can be overridden on a per-task basis via the retries and retry_delay_seconds parameters.