When the R process is forked with future, the child process gets a copy of the event loop, but it should be cleared out in the child process.
Example:
library(later)
library(future)
# Enable forked process
options(future.fork.enable = TRUE)
plan(multicore, workers = 2)
ff <- function(){
message( Sys.getpid())
later::later(ff, 2)
}
ff()
fs <- replicate(2, {
future({
for (i in 1:1000) {
later::run_now(timeout = 1)
}
})
})
This will output:
18235
18241
18242
18235
18241
18242
...
The callback registries should be cleared out when the process is forked. However, we have to be careful about how we do this. What happens if the fork happens in the middle of executing a callback? Is it safe to clear out the C++ data structures at any time that a fork could happen? (Normally the callbacks are removed after being executed.)
This is a follow-up to #141.
When the R process is forked with future, the child process gets a copy of the event loop, but it should be cleared out in the child process.
Example:
This will output:
The callback registries should be cleared out when the process is forked. However, we have to be careful about how we do this. What happens if the fork happens in the middle of executing a callback? Is it safe to clear out the C++ data structures at any time that a fork could happen? (Normally the callbacks are removed after being executed.)