0

R当我在using上执行查询时ROracle,有时查询似乎挂起,我无法停止执行CTRL+C或点击ESC. 我可以做些什么(Win7 上的 R.2.15.2)来停止查询并返回R>

4

1 回答 1

1

我过去用于不间断 R 代码的一个技巧是在对parallel::mcparallel. 然后,如果它挂起,我可以终止分叉进程并继续进入主 R 进程。例子:

function.that.hangs <- function(...) system("while true; do echo hello; sleep 1; done")

# This might hang
result <- function.that.hangs(...)

# Do this instead, the run the function in a forked process.
p <- mcparallel(function.that.might.hang(...))
# This might still hang, but you can kill the stuck R process and it will return.
result <- mmcollect(p)[[1]]

(这个例子可能不会阻止你使用 CTRL+C,但你明白了。

于 2013-03-18T18:05:15.847 回答