Hi! Silly question: I have a somewhat flaky task t...
# ask-community
d
Hi! Silly question: I have a somewhat flaky task that fails sometimes, so I wrapped the function in
@task(max_retries=10, retry_delay=timedelta(minutes=5))
. But the failure is “silent”, in that it’s wrapped by a lower-level library. I know how to check whether it’s failed, so how should I tell Prefect that the task failed (and retry?) — is it enough to
raise prefect.engine.signals.FAIL
? Or does it need to be an explicit
raise ValueError
or something?
z
Hey @Danny Vilela -- either raising a failure signal or throwing an exception should do it
🙌 1
d
@Zanie awesome — thank you!
Quick question: how does the
RETRY
signal fit here? Will it only
RETRY
if you’ve decorated the appropriate function task parameters? Or…retry indefinitely?
z
Ah I think if you raise the RETRY signal manually, you are overriding the retry logic attached to the task. I'm actually not sure what would happen if you mixed them both.
d
Ah gotcha — no worries! I’ll stick with
FAIL
for now. Thanks again Michael 🙏
z
Generally, I'd try not to raise Prefect signals unless you have to
No problem 🙂
d
Ahhhhh so sorry, whenever you’re free: Prefect prefers we raise an exception rather than raise the signal ourselves? Is there a particular reason?
k
I think what Michael is saying that ideally the retry logic should be handled for you, rather than explicitly raising the signals. If there is an error, Prefect will handle those for you.
🙌 1
1
d
Ah, that makes sense! Thanks Kevin