PyDocs

Concurrent Execution

subprocess

not Androidnot iOSnot WASI

Subprocesses with accessible I/O streams

This module allows you to spawn processes, connect to their
input/output/error pipes, and obtain their return codes.

For a complete description of this module see the Python documentation.

Main API
========
run(...): Runs a command, waits for it to complete, then returns a
          CompletedProcess instance.
Popen(...): A class for flexibly executing a command in a new process

Constants
---------
DEVNULL: Special value that indicates that os.devnull should be used
PIPE:    Special value that indicates a pipe should be created
STDOUT:  Special value that indicates that stderr should go to stdout


Older API
=========
call(...): Runs a command, waits for it to complete, then returns
    the return code.
check_call(...): Same as call() but raises CalledProcessError()
    if return code is not 0
check_output(...): Same as check_call() but returns the contents of
    stdout instead of a return code
getoutput(...): Runs a command in the shell, waits for it to complete,
    then returns the output
getstatusoutput(...): Runs a command in the shell, waits for it to complete,
    then returns a (exitcode, output) tuple
Symbols in subprocess

a

ABOVE_NORMAL_PRIORITY_CLASS
A Popen creationflags parameter to specify that a new process will have an above average priority.

b

BELOW_NORMAL_PRIORITY_CLASS
A Popen creationflags parameter to specify that a new process will have a below average priority.

c

call
Run command with arguments.
CalledProcessError
Raised when run() is called with check=True and the process returns a non-zero exit status.
check_call
Run command with arguments.
check_output
Run command with arguments and return its output.
CompletedProcess
A process that has finished running.
CREATE_BREAKAWAY_FROM_JOB
A Popen creationflags parameter to specify that a new process is not associated with the job.
CREATE_DEFAULT_ERROR_MODE
A Popen creationflags parameter to specify that a new process does not inherit the error mode of the calling process.
CREATE_NEW_CONSOLE
The new process has a new console, instead of inheriting its parent’s console (the default).
CREATE_NEW_PROCESS_GROUP
A Popen creationflags parameter to specify that a new process group will be created.
CREATE_NO_WINDOW
A Popen creationflags parameter to specify that a new process will not create a window.

d

DETACHED_PROCESS
A Popen creationflags parameter to specify that a new process will not inherit its parent’s console.
DEVNULL
Special value that can be used as the stdin, stdout or stderr argument to Popen and indicates that the special file os.devnull will be used.

g

getoutput
Return output (stdout or stderr) of executing cmd in a shell.
getstatusoutput
Return (exitcode, output) of executing cmd in a shell.

h

HIGH_PRIORITY_CLASS
A Popen creationflags parameter to specify that a new process will have a high priority.

i

IDLE_PRIORITY_CLASS
A Popen creationflags parameter to specify that a new process will have an idle (lowest) priority.

n

NORMAL_PRIORITY_CLASS
A Popen creationflags parameter to specify that a new process will have a normal priority.

p

PIPE
Special value that can be used as the stdin, stdout or stderr argument to Popen and indicates that a pipe to the standard stream should be opened.
Popen
Execute a child program in a new process.

r

REALTIME_PRIORITY_CLASS
A Popen creationflags parameter to specify that a new process will have realtime priority.
run
Run command with arguments and return a CompletedProcess instance.

s

STARTF_FORCEOFFFEEDBACK
A STARTUPINFO.dwFlags parameter to specify that the mouse cursor will not be changed when launching a process.
STARTF_FORCEONFEEDBACK
A STARTUPINFO.dwFlags parameter to specify that the Working in Background mouse cursor will be displayed while a process is launching.
STARTF_USESHOWWINDOW
Specifies that the STARTUPINFO.wShowWindow attribute contains additional information.
STARTF_USESTDHANDLES
Specifies that the STARTUPINFO.hStdInput, STARTUPINFO.hStdOutput, and STARTUPINFO.hStdError attributes contain additional information.
STARTUPINFO
Partial support of the Windows STARTUPINFO structure is used for Popen creation.
STD_ERROR_HANDLE
The standard error device.
STD_INPUT_HANDLE
The standard input device.
STD_OUTPUT_HANDLE
The standard output device.
STDOUT
Special value that can be used as the stderr argument to Popen and indicates that standard error should go into the same handle as standard output.
SubprocessError
Base class for all other exceptions from this module.
SW_HIDE
Hides the window.

t

TimeoutExpired
This exception is raised when the timeout expires while waiting for a child process.