Skip to content

Commit

Permalink
Add backoff to the first stage
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemahoney218 committed Dec 10, 2020
1 parent a4217cb commit 32e92b9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion R/hit_api.R
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ hit_national_map_api <- function(bbox,
if (!is.null(body$error) &&
counter < 15 &&
(is.null(body$href) && service %in% method$href)) {
Sys.sleep(1)
backoff <- stats::runif(n = 1, min = 0, max = floor(c(
2^counter - 1,
30
)))
Sys.sleep(backoff)
get_href(counter = counter + 1)
} else {
return(body)
Expand Down

0 comments on commit 32e92b9

Please sign in to comment.