What's the best way to retry a task, only in certa...
# ask-community
m
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
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
How do I incude a wait time and/or max retries?
k
You can get the error in the state handler for failed runs using
new_state.result
. Have you seen state handlers?