The class constructor.
Parameters
cmd: str or list
Shell command to execute.
shell: bool
Use intermediate shell between calling python script and process (True) or not (False). True by default. If True then cmd
argument must be a list (just like in the standart subprocess class).
read_chunk: int
Chunk of buffer when reading. Can be adjusted to small values to optimize memory of Python program or to big values if a process which we try to read sends a lot of information to stdout (Python interpreter can hang trying to catch all the output if the value is too small). Default value is ReadingProc._DEFAULT_READ_CHUNK
.
stdin_terminal: bool
Set to True if the program requires virtual terminal to work properly. Example: when calling docker
command. Default value is False.
Iterate raw byte output (not waiting starting a new line).
Parameters
chunk_timeout: float
Timeout to read one item in iter_run() loop.
total_timeout: float
Timeout from start executing process; can only occurs in iter_run() loop.
True if a target process is alive.
Use this function to get a PID. If shell==True, this is the process ID of the spawned shell. To get source correct pid construct ReadingProc with shell=False.
Send bytes to stdin of a target process.
Run the process (call the function after the constructor and before iter_run()).
Kill the process (send SIGKILL).
Try to terminate the process (send SIGTERM).
A class descibing an item which is returned in every loop of ReadingProc.iter_run(). Access to stdout got: data.stdout
, stderr: data.stderr
.
It occurs when we call some methods of ReadingProc before calling start().
It occurs when chunk_timeout occurs while executing iter_run() of ReadingProc.
The exception occurs when total_timeout is expired while executing iter_run() of ReadingProc.