tests/requestCore.R

source("incl/start.R")

message("*** requestCore() ...")

message("*** requestCore() - exceptions ...")

## There are no cores to choose from
res <- try(requestCore(function() {}, workers = 0), silent = TRUE)
stopifnot(inherits(res, "try-error"))

res <- try(requestCore(function() {}, timeout = -1.0), silent = TRUE)
stopifnot(inherits(res, "try-error"))

res <- try(requestCore(function() {}, alpha = 0.0), silent = TRUE)
stopifnot(inherits(res, "try-error"))

message("*** requestCore() - exceptions ... DONE")


if (supportsMulticore()) {
  message("*** requestCore() - timeout ...")
  
  plan(multicore, workers = 2L)
  a %<-% { Sys.sleep(2); 1 }
  
  ## Fake single-worker multicore by using workers = 1L
  res <- try(requestCore(function() {}, workers = 1L, timeout = 0.5, delta = 0.1))
  stopifnot(inherits(res, "try-error"))
  stopifnot(a == 1)
  
  message("*** requestCore() - timeout ... DONE")
}

message("*** requestCore() ... DONE")

source("incl/end.R")

Try the future package in your browser

Any scripts or data that you put into this service are public.

future documentation built on Sept. 11, 2024, 7:35 p.m.