Fix some issues around max_time in _next_wait #136
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.