Skip to contents

Run a function (job) in another session

Usage

start_job(
  fun,
  fun_args = list(),
  packages = NULL,
  workdir = NULL,
  method = c("rs_job", "callr"),
  name = NULL
)

check_job(job_id)

resolve_job(
  job_id,
  timeout = Inf,
  auto_remove = TRUE,
  unresolved = c("warning", "error", "silent")
)

remove_job(job_id)

Arguments

fun

function to evaluate

fun_args

list of function arguments

packages

list of packages to load

workdir

working directory; default is temporary path

method

job type; choices are 'rs_job' and 'callr'

name

name of the job

job_id

job identification number

timeout

timeout in seconds before the resolve ends; jobs that are still running are subject to unresolved policy

auto_remove

whether to automatically remove the job if resolved; default it true

unresolved

what to do if the job is still running after timing-out; default is 'warning' and return NULL, other choices are 'error' or 'silent'

Value

For start_job, a string of job identification number; check_job returns the job status; resolve_job returns the function result.

Examples


if (FALSE) { # \dontrun{


fun <- function() {
  Sys.sleep(2)
  Sys.getpid()
}

job_id <- start_job(fun)

check_job(job_id)

result <- resolve_job(job_id)

} # }