@@ -585,6 +585,28 @@ loggedError.BatchtoolsFuture <- function(future, ...) {
585585} # loggedError()
586586
587587
588+ batchtools_getLog <- function (id , reg , timeout = NULL ) {
589+ debug <- isTRUE(getOption(" future.debug" ))
590+ if (debug ) {
591+ mdebug_push(" batchtools::getLog() ..." )
592+ on.exit(mdebug_pop())
593+ }
594+
595+ if (! is.null(timeout )) {
596+ stopifnot(length(timeout ) == 1 , is.numeric(timeout ), ! is.na(timeout ), timeout > = 0.0 )
597+ oldValue <- reg $ cluster.functions $ fs.latency
598+ on.exit({
599+ reg $ cluster.functions $ fs.latency <- oldValue
600+ }, add = TRUE )
601+ reg $ cluster.functions $ fs.latency <- timeout
602+ }
603+
604+ tryCatch(suppressWarnings({
605+ getLog(id = id , reg = reg )
606+ }), error = function (e ) NULL )
607+ } # # batchtools_getLog()
608+
609+
588610# ' @importFrom batchtools getLog
589611# ' @export
590612loggedOutput.BatchtoolsFuture <- function (future , timeout = NULL , ... ) {
@@ -602,19 +624,7 @@ loggedOutput.BatchtoolsFuture <- function(future, timeout = NULL, ...) {
602624 if (! inherits(reg , " Registry" )) return (NULL )
603625 jobid <- config $ jobid
604626
605- out <- local({
606- if (! is.null(timeout )) {
607- stopifnot(length(timeout ) == 1 , is.numeric(timeout ), ! is.na(timeout ), timeout > = 0.0 )
608- oldValue <- reg $ cluster.functions $ fs.latency
609- on.exit(reg $ cluster.functions $ fs.latency <- oldValue )
610- reg $ cluster.functions $ fs.latency <- timeout
611- }
612- tryCatch(suppressWarnings({
613- getLog(id = jobid , reg = reg )
614- }), error = function (e ) NULL )
615- })
616-
617- out
627+ batchtools_getLog(id = jobid , reg = reg , timeout = timeout )
618628} # loggedOutput()
619629
620630
@@ -784,17 +794,10 @@ await <- function(future, cleanup = TRUE, ...) {
784794
785795 if (inherits(result , " FutureResult" )) {
786796 prototype_fields <- c(prototype_fields , " batchtools_log" )
787- result [[" batchtools_log" ]] <- try(local({
788- if (debug ) {
789- mdebug_push(" batchtools::getLog() ..." )
790- on.exit(mdebug_pop())
791- }
792- # # Since we're already collected the results, the log file
793- # # should already exist, if it exists. Because of this,
794- # # only poll for the log file for a second before giving up.
795- reg $ cluster.functions $ fs.latency <- 1.0
796- getLog(id = jobid , reg = reg )
797- }), silent = TRUE )
797+ # # Since we're already collected the results, the log file
798+ # # should already exist, if it exists. Because of this,
799+ # # only poll for the log file for a second before giving up.
800+ result [[" batchtools_log" ]] <- batchtools_getLog(id = jobid , reg = reg , timeout = 1.0 )
798801 if (result_has_errors(result )) cleanup <- FALSE
799802 }
800803 } else if (" error" %in% stat ) {
0 commit comments