-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Prevent an exception with large num_retries. #502
Conversation
If the calculated wait time is infinite, don't try to do further calculations on it to prevent it from becoming NaN. This could happen if num_retries becomes too large (>1024).
@@ -401,7 +401,7 @@ def calc_retry_wait | |||
# secondary retry | |||
@retry_wait * (2 ** (@num_errors - 2 - @retry_limit)) | |||
end | |||
retry_wait = wait + (rand * (wait / 4.0) - (wait / 8.0)) | |||
retry_wait = wait.infinite? ? wait : wait + (rand * (wait / 4.0) - (wait / 8.0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about wait.finite? ? wait + (rand * (wait / 4.0) - (wait / 8.0)) : wait
?
finite?
covers nan
and infinity
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
Prevent an exception with large num_retries.
Good catch! |
Prevent an exception with large num_retries.
cherry-picked to v0.10 branch |
If the calculated wait time is infinite, don't try to do
further calculations on it to prevent it from becoming NaN.
This could happen if num_retries becomes too large (>1024).
Fixes issue #501