diff --git a/DESCRIPTION b/DESCRIPTION index 84a8c73e..fdfdf5fe 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: parallelly -Version: 1.36.0-9015 +Version: 1.36.0-9016 Title: Enhancing the 'parallel' Package Imports: parallel, diff --git a/NEWS.md b/NEWS.md index 74eca284..d399d8b5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,10 +4,11 @@ * `makeClusterPSOCK(nworkers)` gained protection against setting up too many localhost workers relative to number of available CPU - cores. If `nworkers / availableCores()` greater than 1.0 (100%), - then a warning is produced. If greater than 2.0 (200%), an error - is produced. These limits can be configured by R option - `parallelly.maxWorkers.localhost`. + cores. If `nworkers / availableCores()` greater than 1.0 (100%), + then a warning is produced. If greater than 2.0 (200%), an error is + produced. These limits can be configured by R option + `parallelly.maxWorkers.localhost`. These checks are skipped if + `nworkers` inherits from `AsIs`, e.g. `makeClusterPSOCK(I(16))`. ## Miscellaneous diff --git a/R/availableCores.R b/R/availableCores.R index 28a18d78..bd3e18b1 100644 --- a/R/availableCores.R +++ b/R/availableCores.R @@ -536,6 +536,8 @@ getNproc <- function(ignore = c("OMP_NUM_THREADS", "OMP_THREAD_LIMIT")) { checkNumberOfLocalWorkers <- function(workers) { + if (inherits(workers, "AsIs")) return() + rhos <- getOption("parallelly.maxWorkers.localhost", c(1.0, 2.0)) if (length(rhos) == 0) return() diff --git a/R/makeClusterPSOCK.R b/R/makeClusterPSOCK.R index 7a3710de..852eda15 100644 --- a/R/makeClusterPSOCK.R +++ b/R/makeClusterPSOCK.R @@ -72,7 +72,8 @@ makeClusterPSOCK <- function(workers, makeNode = makeNodePSOCK, port = c("auto", if (length(workers) != 1L) { stopf("When numeric, argument 'workers' must be a single value: %s", length(workers)) } - workers <- as.integer(workers) + + workers <- structure(as.integer(workers), class = class(workers)) if (is.na(workers) || workers < 1L) { stopf("Number of 'workers' must be one or greater: %s", workers) }