Skip to content

Commit

Permalink
Merge pull request #92 from shikokuchuo/dev
Browse files Browse the repository at this point in the history
daemon() records initial state of global environment
  • Loading branch information
shikokuchuo authored Dec 29, 2023
2 parents 52b86ec + e9cdab9 commit b8edac1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: mirai
Type: Package
Title: Minimalist Async Evaluation Framework for R
Version: 0.11.3.9002
Version: 0.11.3.9003
Description: Lightweight parallel code execution and distributed computing.
Designed for simplicity, a 'mirai' evaluates an R expression asynchronously,
on local or network resources, resolving automatically upon completion.
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# mirai 0.11.3.9002 (development)
# mirai 0.11.3.9003 (development)

* Adds `local_url()` helper to construct a random inter-process communications URL for local daemons (thanks @noamross #90).
* `daemon()` argument 'autoexit' now accepts a signal value such as `tools::SIGINT` in order to raise it upon exit.
* `daemon()` now records the state of initial global environment objects (e.g. those created in .Rprofile) for cleanup purposes (thanks @noamross #91).
* Eliminates potential memory leaks along certain error paths.
* Requires nanonext >= [0.11.0.9001].

Expand Down
5 changes: 4 additions & 1 deletion R/daemon.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ daemon <- function(url, autoexit = TRUE, cleanup = TRUE, output = FALSE,
close(devnull)
}, add = TRUE)
}
`[[<-`(`[[<-`(`[[<-`(., "op", .Options), "se", search()), "vars", ".Random.seed")
snapshot()
count <- 0L
start <- mclock()

Expand Down Expand Up @@ -212,3 +212,6 @@ perform_cleanup <- function(cleanup) {
if (cleanup[3L]) options(.[["op"]])
if (cleanup[4L]) gc(verbose = FALSE)
}

snapshot <- function() `[[<-`(`[[<-`(`[[<-`(., "op", .Options), "se", search()), "vars", names(.GlobalEnv))

2 changes: 0 additions & 2 deletions R/mirai.R
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,6 @@ mk_mirai_error <- function(e) {
`class<-`(msg, c("miraiError", "errorValue", "try-error"))
}

snapshot <- function() `[[<-`(`[[<-`(`[[<-`(., 'vars', names(.GlobalEnv)), 'se', search()), 'op', .Options)

.interrupt_error <- `class<-`("", c("miraiInterrupt", "errorValue", "try-error"))
.snapshot <- expression(mirai:::snapshot())
.timedelay <- expression(nanonext::msleep(500L))

0 comments on commit b8edac1

Please sign in to comment.