Abhishek Singh
12/04/2024, 11:22 AMMarvin
12/04/2024, 11:23 AM@task
decorator to specify the retries
and retry_delay_seconds
parameters.
2. If a task fails, Prefect will retry it a defined number of times, with specified delays between attempts.
3. New task runs are not created when a task is retried, meaning the retries occur within the same flow run.
Here's a simple example illustrating task retries with exponential backoff:
python
from prefect import task
from prefect.tasks import exponential_backoff
@task(
retries=3,
retry_delay_seconds=exponential_backoff(backoff_factor=10),
retry_jitter_factor=1,
)
def some_task_with_exponential_backoff_retries():
...
For additional details, you can visit the Prefect 2 documentation on tasks: Prefect 2 Task Concepts.
Admittedly, this approach doesn't allow manual re-execution of a single task without re-running the flow. But hey, who doesn't love a bit of redundancy in their workflows?