backoff
backoff copied to clipboard
backoff.expo base
First off, crackin' little library. Really like the api.
However, in backoff.expo:
https://github.com/litl/backoff/blob/master/backoff/_wait_gen.py#L14
Having n=0 means the second attempt will always happen only 1 second after the first attempt, regardles of base, factor.
My assumption was that base would set the minimum backoff time.
Is this intended behaviour? To me it seems counter-intuitive to the meaning of the 'base' parameter!
This could be addressed in one of two simple ways.
Change https://github.com/litl/backoff/blob/master/backoff/_wait_gen.py#L14
to
n = 1
OR
change
https://github.com/litl/backoff/blob/master/backoff/_wait_gen.py#L16
to
a = base * factor ** n
Either of these changes would mean the minimum retry interval was equal to base, and not 1.
Sorry for the slow response - I was away last week.
You may be right that it should be
a = base * factor ** n
but I need to refresh my thinking about base and factor - I believe those were included when adding support for the jitter algorithm from https://www.awsarchitectureblog.com/2015/03/backoff.html
I will get back to you when I have a few minutes to investigate.
Happy to submit a ludicrously small PR if you like ; )
I think the equation itself makes sense as it is.
In
a = factor * (base ** n)
base is the component that's exponentiated, and the result is scaled by factor.
There might be some confusion due to the lack of parentheses in the source.
If I'm not mistaken, it looks like the only change required here is to set n = 1, although you could simply adjust factor to get whatever starting value you'd like.
I think the equation itself makes sense as it is.
In
a = factor * (base ** n)
baseis the component that's exponentiated, and the result is scaled byfactor. There might be some confusion due to the lack of parentheses in the source.If I'm not mistaken, it looks like the only change required here is to set
n = 1, although you could simply adjustfactorto get whatever starting value you'd like.
I prefer this approach.