Skip to content

Instantly share code, notes, and snippets.

@DavisVaughan
Created May 7, 2020 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavisVaughan/8c312948b2c5943662312017ab54357e to your computer and use it in GitHub Desktop.
Save DavisVaughan/8c312948b2c5943662312017ab54357e to your computer and use it in GitHub Desktop.
fn <- function() {
FUN <- function(x) {
data.table::getDTthreads()
}
parallel::mclapply(1:2, FUN, mc.cores = 2)
}
# Call `getDTthreads()` from the workers
# Should return 1 because we forked
fn()
# Now start it up in a separate process,
# then do the mclapply call which creates
# two workers to run getDTthreads() in.
# The two workers should be forks of the process, so
# why is this 6?
callr::r(fn)
@DavisVaughan
Copy link
Author

See ?getDTthreads for documentation about data.table switching to use 1 thread in forked workers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment