<@ULVA73B9P> do flows support custom retry logic o...
# marvin-in-the-wild
o
@Marvin do flows support custom retry logic or even a list of retry delays? I only see documentation for that support in tasks.
m
Custom retry logic and lists of retry delays appear to be supported for tasks in Prefect rather than at the flow level. You can use
retry_delay_seconds
to define a list of delays for custom retry behavior and
retry_condition_fn
to specify a custom callable that returns a boolean to determine whether to retry a task. For instance, to define successive retry intervals, you might annotate a task like this:
Copy code
python
from prefect import task

@task(retries=3, retry_delay_seconds=[1, 10, 100])
def some_task_with_manual_backoff_retries():
    pass
If you wish to add jitter to your retries to avoid thundering herd problems, the
retry_jitter_factor
option allows for variance in the base delay:
Copy code
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():
    pass
However, it's important to note that these features are for task retries, and the documentation I found does not show similar configurations directly available for flows. For more tailored retries at the flow level, one would likely need to handle retry logic manually. You can review the specifics of task retry configuration in the Prefect documentation.
b
Hey Omar! You can define
retries
and
retry_delay_seconds
in your flow decorator as well.
o
@Bianca Hoch thanks. I saw that in the documentation, but wanted the additional flexibility that the task retries provide.
b
Gotcha, thanks Omar. Just to clarify, what custom retry logic are you looking to use for your flows? 👀 exponential backoff?
o
Yes, exponential backoff to start, jitter too.