ROracle挂起,我该如何取消查询

时间:2013-03-18 16:40:11

标签: oracle r

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

1 个答案:

答案 0 :(得分: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,但你明白了。