Join Slack
Powered by
What's the best way to retry a task, only in certa...
# ask-community
m
Marc Lipoff
03/17/2022, 6:11 PM
What's the best way to retry a task, only in certain scenarios? For example, I'm pulling from an API. I only want to retry (after 30s) if I get a 429 code (rate limited)
s
Stéphan Taljaard
03/17/2022, 6:15 PM
Hi Marc! I'm not sure of exact details, but I think you can add an if statement for those that you
want
to retry, the use signals to indicate that those should be retried
https://docs.prefect.io/api/latest/engine/signals.html#retry
m
Marc Lipoff
03/17/2022, 6:16 PM
How do I incude a wait time and/or max retries?
k
Kevin Kho
03/17/2022, 6:21 PM
You can get the error in the state handler for failed runs using
new_state.result
. Have you seen state handlers?
Open in Slack
Previous
Next