diff --git a/R/multi-req.R b/R/multi-req.R index 9cb4beb4..94afc069 100644 --- a/R/multi-req.R +++ b/R/multi-req.R @@ -75,6 +75,7 @@ req_perform_parallel <- function(reqs, perfs[[i]]$submit(pool) } + progress$update(set = 0) pool_run(pool, perfs, on_error = on_error) progress$done() diff --git a/R/utils.R b/R/utils.R index 91e25166..9cb51b83 100644 --- a/R/utils.R +++ b/R/utils.R @@ -277,12 +277,19 @@ create_progress_bar <- function(total, id <- exec(cli::cli_progress_bar, !!!args) + # These functions are called within multi_req_perform() from curl + # threads so the original progress may have gone away. If that has + # happened we'll just ignore the error. list( - update = function(...) cli::cli_progress_update(..., id = id), - done = function() cli::cli_progress_done(id = id) + update = function(...) try_quiet(cli::cli_progress_update(..., id = id)), + done = function() try_quiet(cli::cli_progress_done(id = id)) ) } +try_quiet <- function(code) { + tryCatch(code, error = function(cnd) NULL) +} + imap <- function(.x, .f, ...) { map2(.x, names(.x), .f, ...) }