0% found this document useful (0 votes)
14 views

Python Topic 1

The document discusses using the subprocess module in Python to manage child processes. Subprocess allows Python programs to run other programs and manage them. Child processes started by Python can run in parallel to utilize all CPU cores and maximize throughput.

Uploaded by

luna
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Python Topic 1

The document discusses using the subprocess module in Python to manage child processes. Subprocess allows Python programs to run other programs and manage them. Child processes started by Python can run in parallel to utilize all CPU cores and maximize throughput.

Uploaded by

luna
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Use subprocess to Manage Child Processes

Python has battle-hardened libraries for running and managing child processes. This
makes Python a great language for gluing other tools together, such as command-line
utilities. When existing shell scripts get complicated, as they often do over time,
graduating them to a rewrite in Python is a natural choice for the sake of
readability and
maintainability.
Child processes started by Python are able to run in parallel, enabling you to use
Python to
consume all of the CPU cores of your machine and maximize the throughput of your
programs. Although Python itself may be CPU bound (see Item 37: “Use Threads for
Blocking I/O, Avoid for Parallelism”), it’s easy to use Python to drive and
coordinate
CPU-intensive workloads.
Python has had many ways to run subprocesses over the years, including popen,
popen2, and os.exec*. With the Python of today, the best and simplest choice for
managing child processes is to use the subprocess built-in module.

You might also like