Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some issues around max_time in _next_wait #136

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Chris2048
Copy link

Added some code & tests around max_time logic of _next_wait.

main motivation here is that I've observed an Overflow in the wait loop;

Without the initial short-circuit before the call to wait.send, the wait function is guaranteed to be called (needlessly). Also it appears that the returned wait time can be negative (if elapsed time is greater than max_time).

When you combine the two, the wait.send function could increase the magnitude of the negative time (e.g. by multiplying or power-ing it) to bigger and bigger magnitudes (in reality it will be getting more negative, and thus smaller, so the min function will keep returning it).

Eventually the size of the number can exceed max range (-2147483648?), and thus we get the OverflowError.

@Kirusi
Copy link

Kirusi commented Jan 31, 2023

I forked the library as https://github.com/Kirusi/improved_backoff. The issue with _next_wait is addressed there, albeit in a slightly different way. If you depend on properly working max_time feel free to use it.

@Chris2048
Copy link
Author

@Kirusi Thanks, I'll have a look at that. TBH I'd been meaning to get back to this with test cases demonstrating the issue, so I'll make a note of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants