Skip to content

Commit

Permalink
ensures legacy dispatcher calls legacy daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Dec 5, 2024
1 parent 36a0259 commit d09c988
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
3 changes: 3 additions & 0 deletions R/daemons.R
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,9 @@ parse_tls <- function(tls)

libp <- function(lp = .libPaths()) lp[file.exists(file.path(lp, "mirai"))][1L]

wa31 <- function(url, dots, rs, tls = NULL)
shQuote(sprintf("mirai::daemon(\"%s\"%s%s,rs=c(%s))", url, dots, parse_tls(tls), paste0(rs, collapse = ",")))

wa3 <- function(url, dots, rs, tls = NULL)
shQuote(sprintf("mirai::daemon(\"%s\"%s%s,rs=c(%s),dispatcher=FALSE)", url, dots, parse_tls(tls), paste0(rs, collapse = ",")))

Expand Down
2 changes: 1 addition & 1 deletion R/dispatcher.R
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ v1_dispatcher <- function(host, url = NULL, n = NULL, ..., retry = FALSE,
}
}

auto && launch_daemon(wa3(nurl, dots, next_stream(envir)), output)
auto && launch_daemon(wa31(nurl, dots, next_stream(envir)), output)

basenames[i] <- burl
servernames[i] <- listurl
Expand Down
11 changes: 4 additions & 7 deletions tests/tests.R
Original file line number Diff line number Diff line change
Expand Up @@ -320,18 +320,16 @@ connection && Sys.getenv("NOT_CRAN") == "true" && {
Sys.sleep(1L)
option <- 15L
Sys.setenv(R_DEFAULT_PACKAGES = "stats,utils")
test_equal(2L, daemons(2, dispatcher = "process", maxtasks = 10L, timerstart = 1L, walltime = 500L, seed = 1546, token = TRUE, cleanup = option, autoexit = tools::SIGCONT))
test_equal(1L, daemons(1, dispatcher = "process", maxtasks = 10L, timerstart = 1L, walltime = 500L, seed = 1546, token = TRUE, cleanup = option, autoexit = tools::SIGCONT))
Sys.unsetenv("R_DEFAULT_PACKAGES")
Sys.sleep(1L)
mq <- mirai(runif(1L), .timeout = 1000)
test_true(is.numeric(mq[]))
mq <- mirai(Sys.sleep(0.7), .timeout = 500)
test_class("matrix", status()[["daemons"]])
test_type("character", saisei(i = 2L, force = TRUE))
m <- mirai(mirai::daemon(url), url = nextget("urls")[2L])
Sys.sleep(0.1)
test_null(saisei(i = 1L))
test_type("integer", mirai(1L, .timeout = 500)[])
test_type("character", saisei(i = 1L, force = TRUE))
Sys.sleep(0.1)
test_zero(daemons(0))
}
# additional legacy interface tests
Expand All @@ -340,10 +338,9 @@ connection && .Platform[["OS.type"]] != "windows" && Sys.getenv("NOT_CRAN") == "
test_equal(daemons(url = host_url(ws = TRUE, tls = TRUE), dispatcher = "thread", output = TRUE), 1L)
test_equal(nextget("n"), 1L)
test_equal(length(nextget("urls")), 1L)
Sys.sleep(1L)
test_class("matrix", status()$daemons)
test_null(saisei(i = 0L))
test_type("character", saisei(i = 1L))
test_print(saisei(i = 1L))
Sys.sleep(0.1)
test_zero(daemons(0))
}
Expand Down

0 comments on commit d09c988

Please sign in to comment.