Skip to content

Commit 5f7cdd2

Browse files
BUG FIX: Use correct future registry name
1 parent bbc2226 commit 5f7cdd2

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: future.batchtools
2-
Version: 0.12.2-9959
2+
Version: 0.12.2-9961
33
Depends:
44
R (>= 3.2.0),
55
parallelly,

R/BatchtoolsFutureBackend-class.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,8 +1066,7 @@ stopWorkers.BatchtoolsFutureBackend <- function(backend, ...) {
10661066
on.exit(mdebugf_pop())
10671067
}
10681068

1069-
reg <- backend[["reg"]]
1070-
futures <- FutureRegistry(reg, action = "list", earlySignal = FALSE)
1069+
futures <- FutureRegistry(backend[["reg"]], action = "list", earlySignal = FALSE)
10711070

10721071
## Nothing to do?
10731072
if (length(futures) == 0L) return(backend)
@@ -1082,7 +1081,7 @@ stopWorkers.BatchtoolsFutureBackend <- function(backend, ...) {
10821081
futures <- lapply(futures, FUN = cancel, interrupt = TRUE)
10831082

10841083
## Erase registry
1085-
futures <- FutureRegistry(reg, action = "reset")
1084+
futures <- FutureRegistry(backend[["reg"]], action = "reset")
10861085

10871086
backend
10881087
}

R/nbrOfWorkers.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ nbrOfFreeWorkers.BatchtoolsMultiprocessFutureBackend <- function(evaluator, back
112112
## Special case: Infinite number of workers
113113
if (is.infinite(workers)) return(workers)
114114

115-
reg <- backend[["reg"]]
116-
usedWorkers <- length(FutureRegistry(reg, action = "list"))
115+
usedWorkers <- length(FutureRegistry(backend[["reg"]], action = "list"))
117116

118117
workers <- workers - usedWorkers
119118
stop_if_not(length(workers) == 1L, !is.na(workers), workers >= 0L)

R/waitForWorker.R

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ unregisterFuture.BatchtoolsUniprocessFuture <- function(future, ...) NULL
3434

3535
#' @export
3636
registerFuture.BatchtoolsFuture <- function(future, ...) {
37-
freg <- sprintf("workers-%s", class(future)[1])
38-
FutureRegistry(freg, action = "add", future = future, earlySignal = FALSE, ...)
37+
backend <- future[["backend"]]
38+
FutureRegistry(backend[["reg"]], action = "add", future = future, earlySignal = FALSE, ...)
3939
}
4040

4141

4242
#' @export
4343
unregisterFuture.BatchtoolsFuture <- function(future, ...) {
44-
freg <- sprintf("workers-%s", class(future)[1])
45-
FutureRegistry(freg, action = "remove", future = future, ...)
44+
backend <- future[["backend"]]
45+
try(FutureRegistry(backend[["reg"]], action = "remove", future = future, ...), silent = TRUE)
4646
}
4747

4848

@@ -73,16 +73,16 @@ waitForWorker.BatchtoolsFuture <- function(future,
7373
stop_if_not(length(timeout) == 1, is.finite(timeout), timeout >= 0)
7474
stop_if_not(length(alpha) == 1, is.finite(alpha), alpha > 0)
7575

76-
freg <- sprintf("workers-%s", class(future)[1])
76+
backend <- future[["backend"]]
7777

7878
## Use a default await() function?
7979
if (is.null(await)) {
80-
await <- function() FutureRegistry(freg, action = "collect-first")
80+
await <- function() FutureRegistry(backend[["reg"]], action = "collect-first")
8181
}
8282

8383
## Number of occupied workers
8484
usedWorkers <- function() {
85-
length(FutureRegistry(freg, action = "list", earlySignal = FALSE))
85+
length(FutureRegistry(backend[["reg"]], action = "list", earlySignal = FALSE))
8686
}
8787

8888
t0 <- Sys.time()

0 commit comments

Comments
 (0)