Skip to content

Commit 99f55a6

Browse files
BUG FIX It was not possible to create more than one progressor in with_progress() [#186]
1 parent aa96a66 commit 99f55a6

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: progressr
2-
Version: 0.17.0-9001
2+
Version: 0.17.0-9002
33
Title: An Inclusive, Unifying API for Progress Updates
44
Description: A minimal, unifying API for scripts and packages to report progress updates from anywhere including when using parallel processing. The package is designed such that the developer can to focus on what progress should be reported on without having to worry about how to present it. The end user has full control of how, where, and when to render these progress updates, e.g. in the terminal using utils::txtProgressBar(), cli::cli_progress_bar(), in a graphical user interface using utils::winProgressBar(), tcltk::tkProgressBar() or shiny::withProgress(), via the speakers using beepr::beep(), or on a file system via the size of a file. Anyone can add additional, customized, progression handlers. The 'progressr' package uses R's condition framework for signaling progress updated. Because of this, progress can be reported from almost anywhere in R, e.g. from classical for and while loops, from map-reduce API:s like the lapply() family of functions, 'purrr', 'plyr', and 'foreach'. It will also work with parallel processing via the 'future' framework, e.g. future.apply::future_lapply(), furrr::future_map(), and 'foreach' with 'doFuture'. The package is compatible with Shiny applications.
55
Authors@R: c(person("Henrik", "Bengtsson",

NEWS.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# Version (development version)
22

3-
* ...
3+
## Bug Fixes
44

5+
* It was not possible to create more than one progressor in a
6+
`with_progress()` call, resulting in additional progressors being
7+
ignored and warnings on "with_progress() received a progression
8+
'initiate' request" being produced.
9+
510

611
# Version 0.17.0 [2025-10-15]
712

R/with_progress.R

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,18 @@ with_progress <- function(expr, handlers = progressr::handlers(), cleanup = TRUE
229229
},
230230

231231
progression = function(p) {
232-
progression_counter <<- progression_counter + 1
233-
if (debug) message(sprintf("- received a %s (n=%g)", sQuote(class(p)[1]), progression_counter))
234-
235-
if (finished) {
236-
warn_about_too_many_progressions(p)
237-
return()
232+
## Reset, because a new progression was created?
233+
if (p$type == "initiate") {
234+
if (!finished) calling_handler(control_progression("shutdown"))
235+
progression_counter <<- 0
236+
finished <<- FALSE
237+
} else {
238+
progression_counter <<- progression_counter + 1
239+
if (debug) message(sprintf("- received a %s (n=%g)", sQuote(class(p)[1]), progression_counter))
240+
if (finished) {
241+
warn_about_too_many_progressions(p)
242+
return()
243+
}
238244
}
239245

240246
## Don't capture conditions that are produced by progression handlers

0 commit comments

Comments
 (0)