使用devtools :: test()终止子进程时发生并行错误,但使用devtools :: check()

时间:2019-05-22 10:19:11

标签: r parallel-processing devtools testthat

我是writing an R package,具有并行代码

anpl <- function(..., num_cores = 1, ...)

  ...

  theta_transpose <- parallel::mcmapply(anpl_single, 1:n_bootstrap,
                                     MoreArgs = more_args, mc.cores = num_cores)
  ...

其中anpl代表自适应非参数学习。

我测试tests/testthat/test_anpl.R中的代码:

test_that("Adaptive non-parametric learning with posterior samples works", {
  ...
  anpl_samples <- anpl(..., num_cores = 2)
  ...
}

呼叫devtools::check()可以正常工作:

── R CMD check results ─────────────────────────── PosteriorBootstrap 0.0.1 ────
Duration: 1m 15.1s

0 errors ✔ | 0 warnings ✔ | 0 notes ✔

调用devtools::test()会显示并行化错误:

══ Results ═════════════════════════════════════════════════════════════════════
Duration: 59.5 s

OK:       21
Failed:   0
Warnings: 0
Skipped:  0
Error while shutting down parallel: unable to terminate some child processes

我发现与Slurm有关的this issue仍处于打开状态,而与processx有关的this issue与其中的解决方法使用调用parallelprocessx的顺序有关不适用于这里。

有什么问题,我该如何解决?

0 个答案:

没有答案