Process
The scherbelberg.Process
class asynchronously executes a list Popen objects liked via pipes. It is used by the scherbelberg.Command
class for actually running commands. In many ways, scherbelberg.Process
is a more targeted and sophisticated variation on the asyncio subprocess implementation.
The Process
Class
- class scherbelberg.Process(procs, command)
Wrapper around a list of
subprocess.Popen
objects, managing their life-cycle. Mutable.- Parameters
procs (
List
[Popen
]) – A list ofsubprocess.Popen
objects linked via pipes.command (
CommandABC
) – The sourcescherbelberg.Command
object.
- __repr__()
Interactive string representation
- Return type
str
- communicate(returncode=False, timeout=None)
Run process or chain of processes.
- Parameters
returncode (
bool
) – If set toTrue
, returns actual return code and does not raise an exception if the process(es) failed. If set toFalse
, a failed process raises an exception and only data from standard output and standard error streams is returned.timeout (
Union
[float
,int
,None
]) – Total timeout in seconds.
- Return type
Union
[Tuple
[List
[str
],List
[str
],List
[int
],Exception
],Tuple
[List
[str
],List
[str
]]]- Returns
A tuple, the first two elements containing data from standard output and standard error streams. If
returncode
is set toTrue
, the tuple has two additional entries, a list of return codes and an exception object that can be raised by the caller.
- property running: bool
Is any of the processes in the list of
subprocess.Popen
objects still running?- Return type
bool