Skip to content

Commit 9a380e3

Browse files
BUG FIX: future() argument 'stdout' was not used when loading packages [#789]
1 parent c71927f commit 9a380e3

File tree

3 files changed

+33
-29
lines changed

3 files changed

+33
-29
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: future
2-
Version: 1.49.0-9027
2+
Version: 1.49.0-9028
33
Title: Unified Parallel and Distributed Processing in R for Everyone
44
Depends:
55
R (>= 3.2.0)

NEWS.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
worker causes warnings to be escalated immediately to errors on the
2323
worker, which therefore also terminates the future.
2424

25-
* `future()` argument `conditions` was not used when loading and
26-
attaching packages specified via argument `packages`, which
27-
prevented us from excluding, for instance,
28-
`packageStartupMessage`:s, causing them to be displayed in
29-
sequential and multicore processing.
25+
* `future()` arguments `stdout` and `conditions` were not applied
26+
when packages that are specified via argument `packages` where
27+
loaded and attached. This prevented us from excluding, for
28+
instance, `packageStartupMessage`:s, causing them to be displayed
29+
in sequential and multicore processing.
3030

3131
* Now the ClusterFutureBackend tries even harder to shut down
3232
parallel cluster workers when shutting down the backend. If it

R/backend_api-evalFuture.R

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,33 @@ evalFutureInternal <- function(data) {
625625
...future.conditions <- list()
626626

627627

628+
## -----------------------------------------------------------------
629+
## Ignore, capture or discard standard output?
630+
## -----------------------------------------------------------------
631+
if (is.na(stdout)) { ## stdout = NA
632+
## Don't capture, but also don't block any output
633+
} else {
634+
if (stdout) { ## stdout = TRUE
635+
## Capture all output
636+
## NOTE: Capturing to a raw connection is much more efficient
637+
## than to a character connection, cf.
638+
## https://www.jottr.org/2014/05/26/captureoutput/
639+
...future.stdout <- rawConnection(raw(0L), open = "w")
640+
} else { ## stdout = FALSE
641+
## Silence all output by sending it to the void
642+
...future.stdout <- file(
643+
switch(.Platform[["OS.type"]], windows = "NUL", "/dev/null"),
644+
open = "w"
645+
)
646+
}
647+
sink(...future.stdout, type = "output", split = split)
648+
on.exit(if (!is.null(...future.stdout)) {
649+
sink(type = "output", split = split)
650+
close(...future.stdout)
651+
}, add = TRUE)
652+
}
653+
654+
628655
## -----------------------------------------------------------------
629656
## Load and attached backend packages
630657
## -----------------------------------------------------------------
@@ -855,29 +882,6 @@ evalFutureInternal <- function(data) {
855882
expr <- bquote_apply(tmpl_expr_local)
856883
}
857884

858-
## Ignore, capture or discard standard output?
859-
if (is.na(stdout)) { ## stdout = NA
860-
## Don't capture, but also don't block any output
861-
} else {
862-
if (stdout) { ## stdout = TRUE
863-
## Capture all output
864-
## NOTE: Capturing to a raw connection is much more efficient
865-
## than to a character connection, cf.
866-
## https://www.jottr.org/2014/05/26/captureoutput/
867-
...future.stdout <- rawConnection(raw(0L), open = "w")
868-
} else { ## stdout = FALSE
869-
## Silence all output by sending it to the void
870-
...future.stdout <- file(
871-
switch(.Platform[["OS.type"]], windows = "NUL", "/dev/null"),
872-
open = "w"
873-
)
874-
}
875-
sink(...future.stdout, type = "output", split = split)
876-
on.exit(if (!is.null(...future.stdout)) {
877-
sink(type = "output", split = split)
878-
close(...future.stdout)
879-
}, add = TRUE)
880-
}
881885

882886
## Prevent 'future.plan' / R_FUTURE_PLAN settings from being nested
883887
options(future.plan = NULL)

0 commit comments

Comments
 (0)