backoff icon indicating copy to clipboard operation
backoff copied to clipboard

max_retries

Open axshani opened this issue 3 years ago • 1 comments

Hi! I'm using @on_predicate and sending max_retries parameter 0. I saw that the failing requests are continue to fire and tried to debug. I think that in case of 0 max_retries the backoff library is entering a infinite loop and keeps on trying the failing request.

tries += 1 there is a check tries == max_tries tries is starting at 1 and max_tries is always 0 in my case. Also, what will heppend if I will pass a negative max_tries parameter?

please fix this thanks

axshani avatar Nov 29 '22 12:11 axshani

https://github.com/litl/backoff/blob/d82b23c42d7a7e2402903e71e7a7f03014a00076/backoff/_sync.py#L50 https://github.com/litl/backoff/blob/d82b23c42d7a7e2402903e71e7a7f03014a00076/backoff/_async.py#L78

It should be max_tries_exceeded = tries >= max_tries_value

nachitox avatar Feb 07 '23 19:02 nachitox