New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
R Session does not start with r_session wait=FALSE #90
Comments
You need to make rs2 <- callr::r_session$new(wait = FALSE)
rs2$poll_process(1000)
rs2$read()
rs2$run(function() 1+1) |
Ahh interesting! So even if you don't poll, it seems you need to call
|
It seems this is also the case for I think this makes the I suspect there is a feature request in here somewhere, but would love your thoughts on what it might be 😄 |
You are right, it does not have a queue. It can only run one thing at a time. The idea is that callr is only the basic infrastructure, and the queue or process pool would be implemented on top of it. E.g. https://github.com/r-lib/async/tree/feature/event-loop has a worker pool, but this only works on Unix currently. The benefit of this is that it can mix other kinds of async computation an IO together. E.g. this runs 1) a timer, 2) HTTP, 3) a generic external process, 4) a callr-like fresh R process, and 5) a function call on the worker pool, all in parallel: afun <- async(function() {
when_all(
delay = delay(1/1000)$
then(function() 1),
http = http_get("https://eu.httpbin.org/status/418")$
then(function(x) x$status_code),
process = run_process("pwd")$
then(function(x) str_trim(x$stdout)),
r_process = run_r_process(function() 2)$
then(function(x) x$result),
call = call_function(function() 3)$
then(function(x) x$result)
)
})
res <- synchronise(afun())
expect_equal(
res,
list(delay = 1,
http = 418,
process = getwd(),
r_process = 2,
call = 3)
) Considering that there is no timeline for releasing that package, though, it might be worth thinking about adding a simple worker pool on top of |
I'll close this. We might have a small worker pool before the fate of the async package is sorted out, but considering that its API would need some time to mature, it is better to put it in another package. |
On RStudio Server Pro (Ubuntu), it looks like
wait = FALSE
causes the R session to never start / become available (even after waiting a while). Furthermore, it foolscallr
's understanding of session state, so that it looks like it is available.Session info
The text was updated successfully, but these errors were encountered: