Skip to content

Commit

Permalink
Patch parallelly 1.20.0 when package is loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikBengtsson committed Oct 22, 2020
1 parent 3ba58a3 commit 58c08f1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
16 changes: 16 additions & 0 deletions R/998.patchParallelly.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## https://github.com/HenrikBengtsson/parallelly/issues/23
patchParallelly <- function() {
ns <- getNamespace("parallelly")
fcn <- get("session_info", mode = "function", envir = ns)
## Already patched?
if (!is.null(attr(fcn, "patched"))) return(invisible(fcn))

formals(fcn)$pkgs <- FALSE
attr(fcn, "patched") <- TRUE

base:::unlockBinding("session_info", env = ns)
assign("session_info", fcn, envir = ns)
base:::lockBinding("session_info", env = ns)

invisible(fcn)
}
5 changes: 5 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
debug <- isTRUE(as.logical(Sys.getenv("R_FUTURE_DEBUG", FALSE)))
if (debug) options(future.debug = TRUE)
debug <- getOption("future.debug", debug)

if (packageVersion("parallelly") <= "1.20.0") {
patchParallelly()
if (debug) mdebug("Patched a bug in parallelly 1.20.0")
}

if (debug) {
envs <- Sys.getenv()
Expand Down

0 comments on commit 58c08f1

Please sign in to comment.