【发布时间】:2018-05-28 17:45:00
【问题描述】:
我想向 CRAN 提交一个使用 parallel::makeCluster(parallel::detectCores()) 进行并行计算的包。
当我构建包时一切正常,但是当我检查包时 (devtools::check(document = FALSE)) 它返回错误:
Running examples in ‘TESTER-Ex.R’ failed
The error most likely occurred in:
> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: hello_world
> ### Title: Prints hello world
> ### Aliases: hello_world
>
> ### ** Examples
>
> hello_world()
Error in .check_ncores(length(names)) : 8 simultaneous processes spawned
Calls: hello_world -> <Anonymous> -> makePSOCKcluster -> .check_ncores
Execution halted
我在 MWE 包 (TESTER) 中重新创建了错误,它只有一个函数 hello_world,我已将整个 TESTER-package 上传到 GitHub,但它应该可以从以下函数重现。
#' Prints hello world
#'
#' @return nothing
#' @export
#'
#' @examples
#' hello_world()
hello_world <- function() {
# initiate cluster
cl <- parallel::makeCluster(parallel::detectCores())
# stop cluster
parallel::stopCluster(cl)
cat("Hello World\n")
return(invisible(NULL))
}
我查看了Writing R Extensions,但找不到与此问题相关的任何内容,也找不到关于 SO 的问题。
任何想法导致此错误以及如何解决它?
【问题讨论】: