Skip to content
This repository was archived by the owner on Aug 8, 2025. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants