Skip to content

Commit

Permalink
Avoid writing to closed progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
richfitz committed Dec 13, 2024
1 parent 6df764d commit 1df64dd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/progress.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ progress_bar_fancy <- function(n_chains, n_steps, show_overall,
update <- function(chain_id, at) {
## Avoid writing into a closed progress bar, it will cause an
## error. We do this by checking to see if progress has changed
## from last time we tried updating.
changed <- any(e$n[chain_id] != at, na.rm = TRUE)
if (changed) {
## from last time we tried updating, or if we're simply
## incomplete.
if (any(at < n_steps | at > e$n)) {
e$n[chain_id] <- at
cli::cli_progress_update(id = id, set = sum(e$n))
}
cli::cli_progress_update(id = id, set = sum(e$n))
}

fail <- function() {
Expand Down

0 comments on commit 1df64dd

Please sign in to comment.