R/utils,mirai.R

Defines functions get_mirai_daemons

#' @importFrom mirai status is_error_value
#' @importFrom utils capture.output
get_mirai_daemons <- function() {
  status <- status()
  res <- status[["daemons"]]

  if (is_error_value(res)) { # should not assume structure of an error value
    reason <- capture.output(print(res))
    stop(FutureError(sprintf("mirai::status() failed to communicate with dispatcher: %s", reason)))
  }
  
  if (is.character(res)) {
    # returns number of daemons if running without dispatcher
    return(status[["connections"]])
  }
  
  as.data.frame(res)
  
}

Try the future.mirai package in your browser

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

future.mirai documentation built on July 3, 2024, 5:06 p.m.