retrying icon indicating copy to clipboard operation
retrying copied to clipboard

stop_max_delay doesn't work as expected

Open kalessin opened this issue 9 years ago • 1 comments

I am not sure how stop_max_delay is intended to work, but I would expect it would stop retry after have been retrying more than the given time with that parameter. However, actually it works very differently: it just disable retry if the script has been run for more than the given time. This can be easily reproduced with this script:

import time                                                                                                                                                                     
import sys 
from retrying import retry

def retry_on_exception(exception):
    print 'Retrying....'
    return True


@retry(retry_on_exception=retry_on_exception, stop_max_delay=10000, wait_fixed=1000)
def test(sleep):
    time.sleep(sleep)
    assert False


if __name__ == '__main__':
    test(int(sys.argv[1]))

if I run

python test.py 0

you will get 10 retries, one per second, as expected. In this case, the exception is raised as soon as the script starts, that is why the problem is not seen. However, if you run

python test.py 12

(so exception will be raised 12 seconds after the script started), you won't get any retry.

kalessin avatar Jul 08 '16 19:07 kalessin

It works like global timeout. If your single try will be longer than stop_max_delay, it will not be executed again.

alexyr avatar Sep 14 '17 07:09 alexyr