Skip to content

Commit 3287c31

Browse files
BUG FIX: Timeouts when launching 'cluster' and 'multisession' futures would produce an obscure error
1 parent 4459b53 commit 3287c31

4 files changed

Lines changed: 23 additions & 3 deletions

File tree

‎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.80.0-9006
2+
Version: 1.80.0-9007
33
Title: Unified Parallel and Distributed Processing in R for Everyone
44
Depends:
55
R (>= 3.2.0)

‎NEWS.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212

1313
## Bug Fixes
1414

15+
* When launching a 'cluster' or 'multisession' future timed out while
16+
waiting for an available worker, it would produce an obscure
17+
errorinstead of an informative timeout error.
18+
1519
* Waiting for an available 'multicore', 'multisession', and 'cluster'
1620
worker with a timeout greater than 60 seconds could take much
1721
longer than that.

‎R/backend_api-11.ClusterFutureBackend-class.R‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ launchFuture.ClusterFutureBackend <- function(backend, future, ...) {
214214
## rather than worker index? /HB 2025-07-04
215215
node_idx <- requestNode(await = function() {
216216
FutureRegistry(reg, action = "collect-first", earlySignal = TRUE, debug = debug)
217-
}, backend = backend, timeout = timeout, delta = delta, alpha = alpha)
217+
}, backend = backend, timeout = timeout, delta = delta, alpha = alpha, future = future)
218218
workers <- backend[["workers"]] ## Backend might have been updated
219219
future[["node"]] <- node_idx
220220

@@ -1065,7 +1065,7 @@ requestNode <- local({
10651065
if (inherits(con, "connection")) close(con)
10661066
})
10671067

1068-
function(await, backend, timeout, delta, alpha, validateWorker = TRUE) {
1068+
function(await, backend, timeout, delta, alpha, validateWorker = TRUE, future = NULL) {
10691069
debug <- isTRUE(getOption("future.debug"))
10701070
if (debug) {
10711071
mdebug_push("requestNode() ...")

‎inst/testme/test-requestNode.R‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,20 @@ plan(sequential)
4343

4444
message("*** requestNode() - timeout ... DONE")
4545

46+
message("*** requestNode() - timeout when workers occupied ...")
47+
48+
ovalue <- options(future.wait.timeout = 0.5)
49+
plan(cluster, workers = 1L)
50+
51+
f1 <- future({ Sys.sleep(2); 42 })
52+
53+
res <- tryCatch(future(1), error = identity)
54+
print(res)
55+
stopifnot(inherits(res, "FutureError"))
56+
57+
plan(sequential)
58+
options(ovalue)
59+
60+
message("*** requestNode() - timeout when workers occupied ... DONE")
61+
4662
message("*** requestNode() ... DONE")

0 commit comments

Comments
 (0)