Thread
#prefect-community
    Danny Vilela

    Danny Vilela

    1 year ago
    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?
    Michael Adkins

    Michael Adkins

    1 year ago
    Hey @Danny Vilela -- either raising a failure signal or throwing an exception should do it
    Danny Vilela

    Danny Vilela

    1 year ago
    @Michael Adkins 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?
    Michael Adkins

    Michael Adkins

    1 year ago
    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.
    Danny Vilela

    Danny Vilela

    1 year ago
    Ah gotcha — no worries! I’ll stick with
    FAIL
    for now. Thanks again Michael 🙏
    Michael Adkins

    Michael Adkins

    1 year ago
    Generally, I'd try not to raise Prefect signals unless you have to
    No problem 🙂
    Danny Vilela

    Danny Vilela

    1 year ago
    Ahhhhh so sorry, whenever you’re free: Prefect prefers we raise an exception rather than raise the signal ourselves? Is there a particular reason?
    Kevin Kho

    Kevin Kho

    1 year ago
    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.
    Danny Vilela

    Danny Vilela

    1 year ago
    Ah, that makes sense! Thanks Kevin