external_process | R Documentation |
Wrap any processx::process object into a deferred value. The process is created by a generator function.
external_process(process_generator, error_on_status = TRUE, ...)
process_generator |
Function that returns a processx::process object. See details below about the current requirements for the returned process. |
error_on_status |
Whether to fail if the process terminates with a non-zero exit status. |
... |
Extra arguments, passed to |
Deferred object.
Current requirements for process_generator
:
It must take a ...
argument, and pass it to
processx::process$new()
.
It must use the poll_connection = TRUE
argument.
These requirements might be relaxed in the future.
If you want to obtain the standard output and/or error of the
process, then process_generator
must redirect them to files.
If you want to discard them, process_generator
can set them to
NULL
.
process_generator
should not use pipes ("|"
) for the standard
output or error, because the process will stop running if the
pipe buffer gets full. We currently never read out the pipe buffer.
## Not run:
lsgen <- function(dir = ".", ...) {
processx::process$new(
"ls",
dir,
poll_connection = TRUE,
stdout = tempfile(),
stderr = tempfile(),
...
)
}
afun <- function() {
external_process(lsgen)
}
synchronise(afun())
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.