Skip to content

Commit 7fbba93

Browse files
TESTS: Make shutdown of parallel PSOCK clusters robust against some nodes already been terminated
1 parent 3a381e6 commit 7fbba93

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: doFuture
2-
Version: 1.0.2-9005
2+
Version: 1.0.2-9006
33
Title: Use Foreach to Parallelize via the Future Framework
44
Depends:
55
foreach (>= 1.5.0),

inst/testme/test-foreach_dofuture,cluster-missing-doFuture-pkg.R

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,16 @@ setupClusterWithoutPkgs <- function(type = "PSOCK",
4545
attr(cl, "withouts") <- res
4646

4747
cl
48-
}
48+
} ## setupClusterWithoutPkgs()
49+
50+
51+
stopCluster2 <- function(cl) {
52+
for (kk in seq_along(cl)) {
53+
tryCatch(parallel::stopCluster(cl[kk]), error = TRUE)
54+
}
55+
} ## stopCluster2()
56+
57+
4958

5059
cl <- NULL
5160
for (type in types) {
@@ -68,7 +77,7 @@ for (type in types) {
6877
print(res)
6978
stopifnot(inherits(res, "FutureError"))
7079
}
71-
parallel::stopCluster(cl)
80+
stopCluster2(cl)
7281
cl <- NULL
7382

7483
cl <- setupClusterWithoutPkgs(type)
@@ -88,7 +97,7 @@ for (type in types) {
8897
print(res)
8998
stopifnot(inherits(res, "FutureError"))
9099
}
91-
parallel::stopCluster(cl)
100+
stopCluster2(cl)
92101
cl <- NULL
93102

94103
plan(sequential)

inst/testme/test-foreach_dopar,cluster-missing-doFuture-pkg.R

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ setupClusterWithoutPkgs <- function(type = "PSOCK",
4646
attr(cl, "withouts") <- res
4747

4848
cl
49-
}
49+
} ## setupClusterWithoutPkgs()
50+
51+
stopCluster2 <- function(cl) {
52+
for (kk in seq_along(cl)) {
53+
tryCatch(parallel::stopCluster(cl[kk]), error = TRUE)
54+
}
55+
} ## stopCluster2()
5056

5157

5258
cl <- NULL
@@ -70,7 +76,7 @@ for (type in types) {
7076
print(res)
7177
stopifnot(inherits(res, "FutureError"))
7278
}
73-
parallel::stopCluster(cl)
79+
stopCluster2(cl)
7480
cl <- NULL
7581

7682
cl <- setupClusterWithoutPkgs(type)
@@ -90,7 +96,7 @@ for (type in types) {
9096
print(res)
9197
stopifnot(inherits(res, "FutureError"))
9298
}
93-
parallel::stopCluster(cl)
99+
stopCluster2(cl)
94100
cl <- NULL
95101

96102
plan(sequential)

0 commit comments

Comments
 (0)