Skip to content

Commit 42a1d34

Browse files
Interrupted futures are now handled and produce an informative warning
1 parent 6d95183 commit 42a1d34

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
* Add `with(<plan>, <expression>)` method to evaluate an expression,
1919
including futures, using a temporary future plan.
20+
21+
* Interrupted futures are now handled and produce an informative warning.
2022

2123
## Bug Fixes
2224

R/protected_api-signalConditions.R

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ signalConditions <- function(future, include = "condition", exclude = NULL, resi
7878
## Flag condition as signaled
7979
cond[["signaled"]] <- cond[["signaled"]] + 1L
8080
conditions[[kk]] <- cond
81-
81+
8282
if (inherits(condition, "error")) {
8383
## Make sure to update 'signaled' information before we exit.
8484
## Note, 'future' is an environment.
@@ -93,6 +93,17 @@ signalConditions <- function(future, include = "condition", exclude = NULL, resi
9393
condition[["future.info"]] <- cond
9494
}
9595
stop(condition)
96+
} else if (inherits(condition, "interrupt")) {
97+
label <- future[["label"]]
98+
if (is.null(label)) label <- "<none>"
99+
result <- future[["result"]]
100+
when <- result[["finished"]]
101+
session_uuid <- result[["session_uuid"]]
102+
source <- attr(session_uuid, "source")
103+
host <- source[["host"]]
104+
pid <- source[["pid"]]
105+
msg <- sprintf("A future ('%s') of class %s was interrupted at %s, while running on %s (pid %s)", label, class(future)[1], format(when, format = "%FT%T"), sQuote(host), pid)
106+
warning(FutureWarning(msg, future = future))
96107
} else if (inherits(condition, "warning")) {
97108
warning(condition)
98109
} else if (inherits(condition, "message")) {

0 commit comments

Comments
 (0)