R foreach 使用 rpy2 python 永远运行 jupyter 笔记本

问题描述 投票:0回答:1

我有一个 python jupyter 笔记本,我在其中运行一些数据获取代码,该代码为我提供了 fcs 文件列表。我在 R 中使用 fcsparser 与 foreach 并行来解析这些,如下所示:

%%R -i files -o data_fcs
library(dplyr)
library(doParallel)
library(foreach)
library(flowCore)
registerDoParallel(cores=4)
trans = arcsinhTransform(transformationId='arcsinhTransform',a=0,b=(1/5),c=0)
print("a")
data_fcs <- foreach(file=files) %dopar% {
    library(flowCore)
    print(sprintf("%s", file))
    # load fcs file
    fcs = read.FCS(file)........(more code after this)

“a”在 foreach 循环之前打印,但我猜里面的内容永远不会被执行,因为代码只是无限地运行,所以没有打印任何其他内容。我的机器(MacBook pro 笔记本电脑)有 4 个核心。

有时,代码会在大约一分钟内随机运行,然后脚本完成,这对我来说很奇怪。导致此问题的原因可能是什么?谢谢!

python r foreach jupyter-notebook parallel-processing
1个回答
0
投票

我找到了一个“解决方案”,只需在每次成功运行后重新启动 jupyter...似乎现在正在工作

© www.soinside.com 2019 - 2024. All rights reserved.