@@ -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