Questions tagged [callr]

20 questions
5
votes
0 answers

Launching an R background process/thread/etc. using current environment for unit testing

Since callr::r and callr::r_bg launch a background process in a clean environment, they do not fit neatly into unit test paradigms. An R unit test, run via testthat, loads the current development version of the package, but any background process…
jwimberley
  • 1,696
  • 11
  • 24
2
votes
1 answer

How does error management work in callr package?

I'm trying to figure out how to use the error handling in the callr package (which creates sub processes for R). Here is a reprex: rp <- callr::r_bg(function() stop("You should see this"), error = getOption("callr.error",…
JBGruber
  • 11,727
  • 1
  • 23
  • 45
2
votes
0 answers

R Websocket - How to send heartbeat/ping at specific intervals?

Some Websocket servers require a ping to be sent at a specified interval (e.g. every 60 seconds) to keep the connection alive. As the WebSocket object from the websocket package is not exportable, it cannot be loaded into a background session. Is…
2
votes
1 answer

Why doesn't Sys.setenv() take immediate effect in R?

I'm trying to understand some behavior related to setting environmental variables within an R session. Context: on computers with multiple cores, Intel MKL can induce data races during (sufficiently large) matrix multiplies. These data races occur…
alexpghayes
  • 673
  • 5
  • 17
2
votes
1 answer

Run testthat test in separate R session (how to combine the outcomes)

I need to test package loading operations (for my multiversion package) and know that unloading namespaces and stuff is dangerous work. So I want to run every test in a fresh R session. Running my tests in parallel does not meet this demand since it…
Siete
  • 328
  • 3
  • 14
2
votes
1 answer

How do I suppress a random number generation warning with future.callr?

I'm using the future.callr that creates a new thread(?) every time a future is requested so it is calculated separately and the main R script can keep moving on. I'm getting the following warning when my futures come back: Warning…
Roger-123
  • 2,232
  • 1
  • 13
  • 33
2
votes
0 answers

R callr different R version

Is it possible to run callr::r with a different R version than the one currently used? An example would be to call the following from R3.5.1, but execute it with R3.4.1. callr::r( func = R.version.string, r_binary = '..../R3.4.1/bin' #…
Maximilian Mordig
  • 1,333
  • 1
  • 12
  • 16
1
vote
1 answer

How to refer to the .GlobalEnv of the session using callr::r

My understanding of callr::r is that the function I am providing is evaluated in a new session of R. If (for whatever reason) I want to keep the .GlobalEnv of this session, I thought I could do it like this: i_am_defined_on_global_level <-…
thothal
  • 16,690
  • 3
  • 36
  • 71
1
vote
1 answer

running background process in R Shiny

I wrote a script that is supposed to run a background process if a button is pressed. After the process is finished, I would like to work further with the results. Below is my script. The process in this script is 10 seconds sleeping followed by…
WJH
  • 539
  • 5
  • 14
1
vote
1 answer

Pass arguments to callr::r() background process and access them within?

R code can be run in a background process like so callr::r(function(){ 2 * 2 }) # [1] 4 When I attempt this with args I can't figure out how to access them. I tried a few obvious things: callr::r(function(){ 2 * 2 }, args =…
stevec
  • 41,291
  • 27
  • 223
  • 311
1
vote
0 answers

Spawning of nested background/parallel processes fails

I'm trying to build a dockerized R microservice that runs on AWS ECS and involves packages {future}, {future.callr} and {furrr} (and thus implicitly {callr} and {processx}) When I do local testing with a docker container that is limited to 1 CPU and…
Rappster
  • 12,762
  • 7
  • 71
  • 120
1
vote
1 answer

Is it possible to disable `callr` for RMarkdown?

I keep getting the error when trying to build the vignetee for {disk.frame}. And I think it's due to buggy behaviour with {callr} with NSE. Is it possible to not use {callr} with RMarkdown? I think {callr} creates a fresh session of R in the…
xiaodai
  • 14,889
  • 18
  • 76
  • 140
0
votes
0 answers

how to set shiny outputs from inside the function when using callr::r_bg

I have a function which sets some output in a shiny app upon a click of a button. Since this process takes some time I want to run it in background. I really like callr package for this but I am facing some trouble implementing this in my current…
user16024709
  • 151
  • 1
  • 12
0
votes
0 answers

How to run reactive background process in shiny R?

I've written code that runs a long calculation in which, as part of it, several UI elements are updated showing part of the progress and results of the calculations. I would like to make possible for the user to run more than one calculation at the…
David Díaz
  • 141
  • 2
  • 3
  • 16
0
votes
1 answer

When performing multisession work, future_lapply says that a package doesn't exist, but it works fine when running plan(sequential)

When I try to use future_apply with plan(multisession), it says that the package I'm trying to use doesn't exist. When I use plan(sequential) it works fine. I also get the same error when using plan(callr). Here's the error: Error in…
Roger-123
  • 2,232
  • 1
  • 13
  • 33
1
2