btrsync.cmdex¶
Asynchronous execution of subprocess pipelines.
Functions
|
Asynchronous iterator returning started subprocesses connected together as a pipeline. |
|
Execute a series of commands in a pipeline. |
|
Execute a series of commands in a pipeline, capturing standard output and error. |
|
Wait on multiple processes, optionally timing out or aborting on failure. |
- async btrsync.cmdex.create_pipeline(*cmds, stdin=None, stdout=None, stderr=None)[source]¶
Asynchronous iterator returning started subprocesses connected together as a pipeline.
- Parameters
cmds – sequence of
btrsync.util.Cmd-like commands that form the pipelinestdin – standard input of the first command in the pipeline;
Nonemeans inherit from caller. If supplied must be file descriptor or file-like object backed by a file descriptor. If supplied, it is guaranteed to be closed on either success or error.stdout – standard output of the last command in the pipeline;
Nonemeans inherit from caller If supplied must be file descriptor or file-like object backed by a file descriptor.stderr – standard error of all commands in the pipeline;
Nonemeans inherit from caller If supplied must be file descriptor or file-like object backed by a file descriptor.
- Returns
asyncio.subprocess.Processinstances of started processes
- async btrsync.cmdex.ex(*cmds, stdin=None, stdout=None, stderr=None, timeout=None, hard_timeout=True, **kwargs)[source]¶
Execute a series of commands in a pipeline.
- Parameters
cmds – sequence of
btrsync.util.Cmd-like commands that form the pipelinestdin – standard input of the first command in the pipeline;
Nonemeans inherit from callerstdout – standard output of the last command in the pipeline;
Nonemeans inherit from callerstderr – standard error of all commands in the pipeline;
Nonemeans inherit from callertimeout – if not
None, time out after this many secondshard_timeout – if
True, kill spawned processes on timeout, otherwise leave them untouchedkwargs – additional keyword arguments to be passed to
wait_procs()
- Returns
a tuple
(procs, rets): a list of spawnedasyncio.subprocess.Processobjects, in the order specified by cmds, and a list of tuples(process, output), in order of completion, of process objects and their captured(stdout, stderr)output, if any
- async btrsync.cmdex.ex_out(*cmds, stdout=-1, **kwargs)[source]¶
Execute a series of commands in a pipeline, capturing standard output and error.
- Parameters
cmds – sequence of
btrsync.util.Cmd-like commands that form the pipelinestdin – standard input of the first command in the pipeline;
Nonemeans inherit from callertimeout – if not
None, time out after this many seconds; remaining running processes are killed on timeout
- Returns
a list of tuples
(exit_code, output), in the order specified by cmds, of the processes’ exit code and captured(stdout, stderr)output
- async btrsync.cmdex.wait_procs(procs, *, timeout=None, abort=False)[source]¶
Wait on multiple processes, optionally timing out or aborting on failure.
- Parameters
procs – sequence of processes to wait on
timeout – if not
None, time out after this many seconds; running processes are left untouched after timeoutabort – if
True, terminate remaining running processes after an abnormal completion (exit code not 0)
- Returns
a list of tuples
(process, output), in order of completion, of process objects and their captured(stdout, stderr)output, if any