All module’s objects are thread-safe with the following exception: process output iterators (see Iterating over output) are not thread-safe. You mustn’t use the same output iterator from different threads simultaneously. In other case it leads to unexpected results. You also mustn’t use with contexts simultaneously from different threads on the same Process object, because when one thread leaves with context it invalidates an output iterator from another thread which is not thread-safe.
Represents an executable program.
Represents a process.
A Process object doesn’t hold any resources (file descriptors, threads, etc.) until it is executed. If it’s created with _defer = True option (which is default, see Command execution) or executed with execute(), all its resources will be freed and the process will be waited when Process instance with _defer = True option will be created or execute() returns. But if you execute a command in other way by execute(wait = False) or issuing iteration over its output (see Iterating over output), you should always use with context manager to guarantee that the process will be wait()‘ed and all its resources will be freed when the code leaves the with context - not when Python’s garbage collector decide to collect the Process and Process‘ output iterator objects. You aren’t ought to do so, but its very good to do so to be sure in your program’s behaviour.
When code leaves a with context associated with a Process instance, all its output iterators became closed.
Parameters: |
|
---|
Waits for the process termination and closes the output iterator (if created).
Executes the process and returns an iterator to its output.
Shell-style pipelines.
Returns the command string.
Note
Very lazy formatting.
Returns the command string.
Note
Very lazy formatting.
Returns command arguments as it will be executed.
Executes the command.
Parameters: | wait (bool) – if True, calls wait(check_status = check_status) after process execution. |
---|
Kills the process.
Parameters: | signal (int) – signal which will be used to kill the process. |
---|---|
Returns: | True if the process received the signal (which indicates that it’s still running). |
Returns the process’ PID.
Returns the process’ captured raw stderr (if _stderr = PIPE).
Returns the process’ captured raw stdout (if _stdout = PIPE).
Returns the process’ exit status.
Returns the process’ captured stderr (if _stderr = PIPE).
Returns the process’ captured stdout (if _stdout = PIPE).
Waits for the process termination.
Parameters: |
|
---|---|
Returns: | the process exit status |
A value to disable stdin redirection.
A value to disable stdout redirection or configure redirection of stderr to stdout.
A value to disable stderr redirection or configure redirection of stdout to stderr.
A value to configure redirection of stdout/stderr to a pipe.
A class to configure redirection of stdin/stdout/stderr from/to a file.
A class to configure redirection of stdin/stdout/stderr from/to a file.
A base class for all exceptions the module throws.
Raised when a command fails to execute or returns an error exit status code.
Returns the command string.
Returns the process’ captured raw stderr (if _stderr = PIPE).
Returns the process’ captured raw stdout (if _stdout = PIPE).
Returns the process’s exit status.
Returns the process’ captured stderr (if _stderr = PIPE).
Returns the process’ captured stdout (if _stdout = PIPE).
Raised on attempt to start a process with an invalid argument.
Raised on attempt to process an invalid operation on a process.
Raised on attempt to process an operation on a process with an invalid state for this operation.
Raised when process terminates and its output is truncated because one of its children didn’t close the output descriptor.