Skip to content

Commit

Permalink
TESTS: Check that crashed multicore futures are released [#677]
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikBengtsson committed Apr 19, 2023
1 parent af68abc commit f7c11ac
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions tests/multicore,worker-termination.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
source("incl/start.R")
library("listenv")

message("*** multicore() - terminating workers ...")

if (supportsMulticore() && availableCores("multicore") >= 2L) {
plan(multicore, workers = 2L)

all <- nbrOfWorkers()
free <- nbrOfFreeWorkers()
stopifnot(
nbrOfWorkers() == 2L,
nbrOfFreeWorkers() == 2L
)

## Force R worker to quit
x %<-% tools::pskill(pid = Sys.getpid())
res <- tryCatch(y <- x, error = identity)
f <- future({ tools::pskill(pid = Sys.getpid()) })
res <- tryCatch(value(f), error = identity)
print(res)
stopifnot(inherits(res, "FutureError"))

stopifnot(
nbrOfWorkers() == all,
nbrOfFreeWorkers() == free
)
}

message("*** multicore() - terminating workers ... DONE")
Expand Down

0 comments on commit f7c11ac

Please sign in to comment.