在并行运行中启用引用的任何方式

问题描述

我可以通过这个启用引用错误

    options(error = function()  {
  calls <- sys.calls()
  if (length(calls) >= 2L) {
    sink(stderr())
    on.exit(sink(NULL))
    cat("Backtrace:\n")
    calls <- rev(calls[-length(calls)])
    for (i in seq_along(calls)) {
      cat(i,": ",deparse(calls[[i]],nlines = 20L),"\n",sep = "")
    }
    for (i in calls) {
      print(i) #,sep = "")
    }
  }
  if (!interactive()) {
    q(status = 1)
  }
})

如果我在像这样的非并行代码上运行它,效果很好:

f <- function(x) x + 1
g <- function(x) f(x)
g("a")

我只想得到这个引用

    Error in x + 1 : non-numeric argument to binary operator
Backtrace:
1: f(x)
2: g("a")
function(x) f(x)
g("a")

然而,引用在像这样的并行循环的情况下是没有用的:

> cl <- makeCluster(10)
> registerDoParallel(cl)
> d <- foreach (v=c(1:10),.packages=c('data.table','zoo','RcppRoll','bit64') ) %dopar% {
+   
+    
+     b = 6
+     g("a")
+    c = 1 
+ }
Error in { : task 1 Failed - "non-numeric argument to binary operator"
Backtrace:
1: stop(simpleError(msg,call = expr))
2: e$fun(obj,substitute(ex),parent.frame(),e$data)
3: foreach(v= c(1:10),.packages = c("data.table","zoo","RcppRoll","bit64")) %dopar% {    b = 6    g("a")    c = 1}
stop(simpleError(msg,call = expr))
e$fun(obj,e$data)
foreach(v= c(1:10),"bit64")) %dopar% {
    b = 6
    g("a")
    c = 1
}

除了

还有什么办法可以得到更多的细节追踪吗?
Error in { : task 1 Failed - "non-numeric argument to binary operator"

更类似于非并行调用

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)