Thread
#prefect-community
    Maikel Penz

    Maikel Penz

    2 years ago
    Hey.. question about
    task retries
    . Shouldn't the code below
    retry
    only every 30 seconds ? When I run it the output goes from 1 to 40 in less than a second and finishes. I expected it would take 30(seconds) x 40 runs to finish (as per my
    if loop_count == 40:
    to stop)
    from prefect import Flow, task, context
    from prefect.engine.signals import LOOP
    import datetime
    import time
    
    @task(max_retries=50, retry_delay=datetime.timedelta(seconds=30))
    def test_retry():
        loop_count = context.get("task_loop_count", {})
        print(loop_count)
    
        if loop_count == 40:
            return "finished"
    
        raise LOOP(message="Next run")
    
    with Flow("test-pipeline") as flow:
        test_retry()
    
    flow.run()
    Chris White

    Chris White

    2 years ago
    Hi @Maikel Penz - retries only occur whenever a task fails, and it looks like this task should run smoothly every time
    Maikel Penz

    Maikel Penz

    2 years ago
    right.. I thought that using
    raise LOOP(message="Next run")
    would force the next retry
    Chris White

    Chris White

    2 years ago
    ah gotcha - while that is technically an exception, it carries with it an underlying Prefect state signaling what state the task should transition to. A more obvious example would be the
    SUCCESS
    signal, which forceably transitions the task to a
    Success
    state
    Maikel Penz

    Maikel Penz

    2 years ago
    it makes sense.. thanks Chris !
    Chris White

    Chris White

    2 years ago
    anytime!