Skip to content

Instantly share code, notes, and snippets.

@mllg
Created August 30, 2016 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mllg/82410d0f564a7a24251e9e747e210b39 to your computer and use it in GitHub Desktop.
Save mllg/82410d0f564a7a24251e9e747e210b39 to your computer and use it in GitHub Desktop.
Patch for mccollect
Index: src/library/parallel/R/unix/mcparallel.R
===================================================================
--- src/library/parallel/R/unix/mcparallel.R (Revision 71169)
+++ src/library/parallel/R/unix/mcparallel.R (Arbeitskopie)
@@ -52,24 +52,26 @@
if (missing(jobs)) jobs <- children()
if (!length(jobs)) return (NULL)
if (isTRUE(intermediate)) intermediate <- utils::str
+ pids <- if (inherits(jobs, "process") || is.list(jobs))
+ processID(jobs) else jobs
+ if (!length(pids)) return(NULL)
+ if (!is.numeric(pids)) stop("invalid 'jobs' argument")
+ pids <- as.integer(pids)
+ pnames <- as.character(pids)
+ if (!inherits(jobs, "process") && is.list(jobs))
+ for(i in seq(jobs))
+ if (!is.null(jobs[[i]]$name))
+ pnames[i] <- as.character(jobs[[i]]$name)
+
if (!wait) {
s <- selectChildren(jobs, timeout)
if (is.logical(s) || !length(s)) return(NULL)
- lapply(s, function(x) {
+ res <- lapply(s, function(x) {
r <- readChild(x)
if (is.raw(r)) unserialize(r) else NULL
})
+ names(res) <- pnames[match(pids, s, nomatch = 0L)]
} else {
- pids <- if (inherits(jobs, "process") || is.list(jobs))
- processID(jobs) else jobs
- if (!length(pids)) return(NULL)
- if (!is.numeric(pids)) stop("invalid 'jobs' argument")
- pids <- as.integer(pids)
- pnames <- as.character(pids)
- if (!inherits(jobs, "process") && is.list(jobs))
- for(i in seq(jobs))
- if (!is.null(jobs[[i]]$name))
- pnames[i] <- as.character(jobs[[i]]$name)
res <- lapply(pids, function(x) NULL)
names(res) <- pnames
fin <- rep(FALSE, length(jobs))
@@ -85,6 +87,6 @@
if (is.function(intermediate)) intermediate(res)
} else if (all(is.na(match(pids, processID(children()))))) break
}
- res
}
+ res
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment