Skip to content

Commit 415aad8

Browse files
Merge branch 'release/0.10.2'
2 parents 75a8802 + 9748266 commit 415aad8

27 files changed

+115
-184
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: future.callr
2-
Version: 0.10.1
2+
Version: 0.10.2
33
Depends:
44
R (>= 3.4.0),
55
future (>= 1.58.0)
@@ -26,5 +26,5 @@ URL: https://future.callr.futureverse.org, https://github.com/futureverse/future
2626
BugReports: https://github.com/futureverse/future.callr/issues
2727
Language: en-US
2828
Encoding: UTF-8
29-
RoxygenNote: 7.3.2
29+
RoxygenNote: 7.3.3
3030
Roxygen: list(markdown = TRUE)

NEWS.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# Version 0.10.2 [2025-10-10]
2+
3+
## Bug Fixes
4+
5+
* The 'callr' backend was holding on to temporary **callr** files
6+
longer than necessary. Such files were only removed when the future
7+
object itself was removed. This would result in a large number of
8+
temporary files accumulating where there were many futures
9+
processed. Now the 'callr' backend finalizes the 'callr' process as
10+
soon as the future results have been collected, which results in
11+
removing temporary files created by **callr** sooner. Previously,
12+
the finalizer was only run when the future object was removed and
13+
garbage collected.
14+
15+
116
# Version 0.10.1 [2025-07-10]
217

318
## Bug Fixes

R/CallrFutureBackend-class.R

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ launchFuture.CallrFutureBackend <- local({
4848
## MEMOIZATION
4949
evalFuture <- import_future("evalFuture")
5050
getFutureData <- import_future("getFutureData")
51-
with_stealth_rng <- import_future("with_stealth_rng")
51+
with_stealth_rng <- if (packageVersion("processx") >= "3.8.6") {
52+
identity
53+
} else {
54+
import_future("with_stealth_rng")
55+
}
5256

5357
cmdargs <- NULL
5458

@@ -126,7 +130,8 @@ launchFuture.CallrFutureBackend <- local({
126130

127131

128132
## Launch
129-
## WORKAROUND: callr::r_bg() updates the RNG state
133+
## WORKAROUND: callr::r_bg() -> ... -> processx:::get_id() updates
134+
## the RNG state. This was fixed in processx 3.8.6 (2025-02-21).
130135
with_stealth_rng({
131136
future[["process"]] <- r_bg(func, args = r_bg_args, stdout = stdout, stderr = stderr, cmdargs = cmdargs, supervise = supervise)
132137
})
@@ -456,6 +461,10 @@ await <- function(future, ...) {
456461
if (FutureRegistry(reg, action = "contains", future = future)) {
457462
FutureRegistry(reg, action = "remove", future = future)
458463
}
464+
465+
## Finalize the 'callr' process, which includes remove any temporary
466+
## files that it created
467+
process$finalize()
459468
}
460469

461470
## Failed to launch?
@@ -526,6 +535,10 @@ await <- function(future, ...) {
526535

527536
reg <- backend[["reg"]]
528537
FutureRegistry(reg, action = "remove", future = future)
538+
539+
## Finalize the 'callr' process, which includes remove any temporary
540+
## files that it created
541+
process$finalize()
529542

530543
result
531544
} # await()

R/package.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
#' The Future API is defined by the \pkg{future} package.
66
#'
77
#' To use callr futures, load \pkg{future.callr}, and
8-
#' select the type of future you wish to use, e.g. `plan(callr)`.
8+
#' select the type of future you wish to use, e.g.
9+
#' `plan(future.callr::callr)`.
910
#'
1011
#' @examples
1112
#' \donttest{
12-
#' plan(callr)
13+
#' library(future)
14+
#' plan(future.callr::callr)
1315
#' demo("mandelbrot", package = "future", ask = FALSE)
1416
#' }
1517
#'

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ utilizes the **[callr]** package.
2121
For example,
2222

2323
```r
24-
> library(future.callr)
25-
> plan(callr)
24+
> library(future)
25+
> plan(future.callr::callr)
2626
>
2727
> x %<-% { Sys.sleep(5); 3.14 }
2828
> y %<-% { Sys.sleep(5); 2.71 }
@@ -108,8 +108,8 @@ futures are evaluated_. For instance, to use `callr` futures, run the
108108
demo as:
109109

110110
```r
111-
library(future.callr)
112-
plan(callr)
111+
library(future)
112+
plan(future.callr::callr)
113113
demo("mandelbrot", package = "future", ask = FALSE)
114114
```
115115

inst/WORDLIST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ callr
2626
cran
2727
doFuture
2828
doi
29+
finalizer
2930
finalizers
3031
furrr
3132
github

inst/testme/test-callr,launch-failure.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
library(future.callr)
1+
library(future)
22
library(listenv)
33

44
options(future.debug = FALSE)
@@ -7,7 +7,7 @@ message("*** callr() ...")
77

88
message("- Error in ./.Rprofile causes callr process to fail")
99

10-
plan(callr, workers = 2L)
10+
plan(future.callr::callr, workers = 2L)
1111

1212
## STRICTER TEST: Assert that FutureRegistry won't trigger errors
1313
for (kk in seq_len(nbrOfWorkers())) {

inst/testme/test-callr,worker-termination.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
library(future.callr)
1+
library(future)
22

33
message("*** callr() - terminating workers ...")
44

5-
plan(callr, workers = 2L)
5+
plan(future.callr::callr, workers = 2L)
66

77
all <- nbrOfWorkers()
88
free <- nbrOfFreeWorkers()

inst/testme/test-demo.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
library(future.callr)
1+
library(future)
22

33
options(future.demo.mandelbrot.nrow = 2L)
44
options(future.demo.mandelbrot.resolution = 50L)
@@ -8,7 +8,7 @@ message("*** Demos ...")
88

99
message("*** Mandelbrot demo of the 'future' package ...")
1010

11-
plan(callr)
11+
plan(future.callr::callr)
1212
demo("mandelbrot", package = "future", ask = FALSE)
1313

1414
message("*** Demos ... DONE")

inst/testme/test-dotdotdot.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
library(future)
12
library(future.callr)
23
library(listenv)
34

0 commit comments

Comments
 (0)