-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Has re-added code for using value of "retry-after" header as waiting time if status_code = 429 #472
Conversation
…time if status_code = 429. Now also respects value of pause_min.
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.
Can you please also add a note to the documentation (mentioning that it understand the 429 status code), and add a bullet to news following the existing template.
R/retry.R
Outdated
@@ -91,6 +91,10 @@ backoff_full_jitter <- function(i, resp, pause_base = 1, pause_cap = 60, | |||
error_description <- "" | |||
status <- status_code(resp) | |||
} | |||
if (status == 429) { | |||
length_429 <- as.numeric(resp$headers[["retry-after"]]) | |||
if (!is.null(length_429) && length_429 >= pause_min) length <- length_429 |
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.
I don't think the logic is quite right here - length_429
will never be NULL
because you coerce it to numeric
Inside the if
statement, I'd prefer something like length <- max(pause_min, length_429)
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.
Looks good. Just one last small tweak
R/retry.R
Outdated
length_429 <- as.numeric(resp$headers[["retry-after"]]) | ||
if (!is.null(length_429) && length_429 >= pause_min) length <- length_429 | ||
retry_after <- resp$headers[["retry-after"]] | ||
if (!is.null(retry_after)) length <- max(pause_min, as.numeric(retry_after)) |
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.
Can you please put the condition code inside of {}
(indented like the rest of the code)
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.
Was this what you meant?
Perfect, thanks! |
I've reset my fork to the current master and re-added the code changes as discussed on #434.
The code now also respects the value of pause_min.