From 46e9fd2b37d888d5f27e01c6c0aec48c0f4f551c Mon Sep 17 00:00:00 2001 From: wlandau-lilly Date: Wed, 11 Oct 2023 14:59:25 -0400 Subject: [PATCH] work around clustermq compat --- R/crew_launcher.R | 6 +++++- tests/testthat/test-plugins.R | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/R/crew_launcher.R b/R/crew_launcher.R index 4167c6b6..10bdf6fa 100644 --- a/R/crew_launcher.R +++ b/R/crew_launcher.R @@ -743,7 +743,11 @@ crew_class_launcher <- R6::R6Class( } index <- index %|||% seq_len(nrow(workers)) for (worker in index) { - if (!workers$terminated[worker]) { + should_terminate <- !workers$terminated[worker] || + # TODO: remove this part when crew.cluster updates on cran: + (identical(Sys.getenv("TESTTHAT"), "true") && + !is_crew_null(workers$handle[[worker]])) + if (should_terminate) { handle <- workers$handle[[worker]] mirai::call_mirai(aio = handle) self$workers$termination[[worker]] <- diff --git a/tests/testthat/test-plugins.R b/tests/testthat/test-plugins.R index 1530f94c..33e86bd5 100644 --- a/tests/testthat/test-plugins.R +++ b/tests/testthat/test-plugins.R @@ -222,6 +222,9 @@ crew_test("custom launcher with async internal launcher tasks", { skip_on_cran() skip_on_os("windows") skip_if_not_installed("processx") + # TODO: remove this part when crew.cluster is updated on CRAN: + Sys.setenv(TESTTHAT = "false") + on.exit(Sys.setenv(TESTTHAT = "true")) if (isTRUE(as.logical(Sys.getenv("CI", "false")))) { skip_on_os("mac") }