flapili
06/04/2024, 11:57 AMMarvin
06/04/2024, 11:57 AMretry_delay_seconds
in Prefect, you can configure it directly in your task definition. Here’s an example of how to do it, including how to add jitter for varying delay times:
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, # To add jitter to the base delay
)
def some_task_with_exponential_backoff_retries():
# Your task logic here
pass
- retries
: The number of times to retry the task.
- retry_delay_seconds
: The delay before a retry, which can be configured using exponential_backoff
for exponential delays.
- retry_jitter_factor
: (optional) Adds variance to the base delay to prevent the "thundering herd" problem.
You can find more details in the Prefect documentation here.flapili
06/04/2024, 11:58 AMMarvin
06/04/2024, 11:59 AMretry_delay_seconds
is being ignored when specified in a task, as highlighted in the GitHub issue #13764.
### Summary:
- The problem has been replicated and reported across Prefect versions 2.19.3 and 3.0rc1.
- The delay specified in retry_delay_seconds
for tasks does not take effect, while it works correctly at the flow level.
### Example:
Here is a minimal reproduction example from the issue:
python
from datetime import datetime
from prefect import flow, task
@task(retries=3, retry_delay_seconds=5, log_prints=True)
def task_foo():
print(datetime.now())
raise ValueError("foo")
@flow(retries=3, retry_delay_seconds=5, log_prints=True)
def flow_foo():
print(datetime.now())
task_foo()
if __name__ == "__main__":
flow_foo()
### Temporary Workaround:
Until the bug is addressed, you might consider handling retries at the flow level or implementing your own wait logic within the task function if the specific retry delay within tasks is critical.
For up-to-date information and tracking, you can follow the related GitHub issue here.Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.
Powered by