Skip to content

Commit 6372251

Browse files
BUG FIX: result() on a canceled and interrupted cluster future returned the future instead of producing a FutureInterruptError.
1 parent 8ed6c55 commit 6372251

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
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.67.0-9017
2+
Version: 1.67.0-9018
33
Title: Unified Parallel and Distributed Processing in R for Everyone
44
Depends:
55
R (>= 3.2.0)

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ repeat. This release fixes a few more regressions introduced in
1313

1414
## Bug Fixes
1515

16+
* `result()` on a canceled and interrupted cluster future returned
17+
the future instead of producing a FutureInterruptError.
18+
1619
* The `cluster` backend failed when used with an `MPIcluster` as
1720
created by `parallel::makeCluster(..., type = "MPI")`. This bug was
1821
introduced in **future** (>= 1.40.0) [2025-04-10].

R/backend_api-11.ClusterFutureBackend-class.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,11 @@ result.ClusterFuture <- function(future, ...) {
775775
## worker also shutting done? If so, turn the error into a run-time
776776
## FutureInterruptError and revive the worker
777777
future <- handleInterruptedFuture(backend, future = future)
778-
return(future)
778+
stop_if_not(inherits(future, "Future"))
779+
result <- future[["result"]]
780+
if (inherits(result, "FutureError")) stop(result)
781+
stop_if_not(inherits(future, "FutureResult"))
782+
return(result)
779783
}
780784
assertValidConnection(future)
781785
}

inst/testme/test-cancel.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ for (strategy in strategies) {
6060
f <- cancel(f)
6161
}
6262

63-
message(" Create another future")
63+
message(" Create another canceled future")
64+
f <- future({ Sys.sleep(0.5); 42 })
65+
f <- cancel(f)
66+
v <- tryCatch(value(f), FutureInterruptError = identity)
67+
stopifnot(is.numeric(v) || inherits(v, "FutureInterruptError"))
68+
69+
message(" Create yet another future")
6470
## Create another future
6571
f <- future(42)
6672
v <- value(f)

0 commit comments

Comments
 (0)