View source: R/multi-process.R
executeMultiProcess | R Documentation |
Execute a queue of system commands in parallel.
executeMultiProcess(
commandQueue,
finishHandler,
timeoutHandler = function(...) TRUE,
errorHandler = defMultiProcErrorHandler,
prepareHandler = NULL,
cacheName = NULL,
setHash = NULL,
procTimeout = NULL,
printOutput = FALSE,
printError = FALSE,
logSubDir = NULL,
showProgress = TRUE,
waitTimeout = 50,
batchSize = 1,
delayBetweenProc = 0,
method = NULL
)
commandQueue |
A list with commands. Should contain |
finishHandler |
A function that is called when a command has finished.
This function is typically used to process any results generated by the
command. The function is called right after spawning a new process, hence
processing results can occur while the next command is running in the
background. The function signature should be |
timeoutHandler |
A function that is called whenever a timeout for a
command occurs. Should return |
errorHandler |
Similar to |
prepareHandler |
A function that is called prior to execution of the
command. The function signature should be |
cacheName , setHash |
Used for caching results. Set to |
procTimeout |
The maximum time a process may consume before a timeout
occurs (in seconds). Set to |
printOutput , printError |
Set to |
logSubDir |
The sub-directory used for log files. The final log file
path is constructed from patRoon.MP.logPath, |
showProgress |
Set to |
waitTimeout |
Number of milliseconds to wait before checking if a new process should be spawned. Ignored if patRoon.MP.method="future". |
batchSize |
Number of commands that should be executed in sequence per processes. See details. Ignored if patRoon.MP.method="future". |
delayBetweenProc |
Minimum number of milliseconds to wait before spawning a new process. Might be needed to workaround errors. Ignored if patRoon.MP.method="future". |
method |
Overrides patRoon.MP.method if not |
This function executes a given queue with system commands in parallel to speed up computation. Commands are executed in the background using the processx package. A configurable maximum amount of processes are created to execute multiple commands in parallel.
Multiple commands may be executed in sequence that are launched from a single
parent process (as part of a batch script on Windows or combined with the
shell AND operator otherwise). Note that in this scenario still multiple
processes are spawned. Each of these processes will manage a chunk of the
command queue (size defined by batchSize
argument). This approach is
typically suitable for fast running commands: the overhead of spawning a new
process for each command from R would in this case be significant enough to
loose most of the speedup otherwise gained with parallel execution. Note that
the actual batch size may be adjusted to ensure that a maximum number of
processes are running simultaneously.
Other functionalities of this function include timeout and error handling.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.