Skip to content

Commit 1873b50

Browse files
Add 'timeout' argument to loggedOutput(), which is set to zero when collecting terminated futures
1 parent 4fad712 commit 1873b50

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: future.batchtools
2-
Version: 0.12.2-9926
2+
Version: 0.12.2-9927
33
Depends:
44
R (>= 3.2.0),
55
parallelly,

NEWS.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
* Canceling batchtools futures will now interrupt them by default,
1515
if the backend supports it.
16-
16+
1717
* Add built-in template job script for LSF and OpenLava.
1818

1919
## Documentation
@@ -22,6 +22,16 @@
2222
template script to illustrate how to control this runtime via the
2323
backend `resources` argument.
2424

25+
## Bug Fixes
26+
27+
* Calling `value()` on a terminated batchtools job could take 65
28+
seconds to return, because it read logged output to be part of the
29+
error message. When there was no output file, **batchtools** would
30+
wait for the file up to 65 seconds to give job schedulers time to
31+
write output to file. Now **future.batchtools** will no longer wait
32+
for such files and only read their content if they exists when
33+
checked.
34+
2535

2636
# Version 0.12.2 [2025-06-06]
2737

R/BatchtoolsFutureBackend-class.R

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ loggedError.BatchtoolsFuture <- function(future, ...) {
587587

588588
#' @importFrom batchtools getLog
589589
#' @export
590-
loggedOutput.BatchtoolsFuture <- function(future, ...) {
590+
loggedOutput.BatchtoolsFuture <- function(future, timeout = NULL, ...) {
591591
stat <- status(future)
592592
if (is_na(stat)) return(NULL)
593593

@@ -601,7 +601,19 @@ loggedOutput.BatchtoolsFuture <- function(future, ...) {
601601
reg <- config$reg
602602
if (!inherits(reg, "Registry")) return(NULL)
603603
jobid <- config$jobid
604-
getLog(id = jobid, reg = reg)
604+
605+
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+
out <- tryCatch(suppressWarnings({
613+
getLog(id = jobid, reg = reg)
614+
}), error = function(e) NULL)
615+
})
616+
out
605617
} # loggedOutput()
606618

607619

@@ -801,7 +813,7 @@ await <- function(future, cleanup = TRUE, ...) {
801813
## whereas jobs that failed to launch won't. /HB 2025-07-15
802814

803815
hint <- tryCatch({
804-
output <- loggedOutput(future)
816+
output <- loggedOutput(future, timeout = 0.0)
805817
hint <- unlist(strsplit(output, split = "\n", fixed = TRUE))
806818
hint <- hint[nzchar(hint)]
807819
hint <- tail(hint, n = getOption("future.batchtools.expiration.tail", 48L))
@@ -810,7 +822,7 @@ await <- function(future, cleanup = TRUE, ...) {
810822
hint <- c("The last few lines of the logged output:", hint)
811823
hint <- paste(hint, collapse = "\n")
812824
} else {
813-
hint <- "No logged output exist"
825+
hint <- "No logged output file exist"
814826
}
815827

816828
if (any(c("submitted", "started") %in% stat)) {

0 commit comments

Comments
 (0)