Python provides multiple modules for creating sub-processes. I prefer to use the subprocess module because the python manual contains the following:
This module intends to replace several other, older modules and functions, such as: OS. System, OS.
1.2. Popen ObjectsAn instance of the Popen class has the following methods:1. Popen.poll ()Checks whether the child process has ended, sets and returns the return code value.2. Popen.wait ()Waits for the child process to end, sets and returns the
Original: http://blog.chinaunix.net/uid-26000296-id-4461522.htmlIntroduction of Subprocess ModuleThe subprocess was first introduced in version 2.4.The subprocess module is used to generate sub-processes and can be piped to connect their
1. how does PHPpopen implement concurrent execution of multiple processes? the pclose in the loop will wait until the process is completed and then perform the next loop. 2. suppose there are 17 processes to be enabled, how to start 5 processes each
The relevant modules and functions in Python that can execute shell commands are:
Os.system
os.spawn*
os.popen*--Waste
popen2.*--Waste
commands.*-Discarded, removed in 3.x
Import Commandsresult = commands.getoutput ('
This section is another way to learn about process communication: pipelines. A pipeline is a process that connects a stream of data to another process's channel, which typically connects the output of one process to the input of another process
These days tuning program (embedded Linux), the discovery program sometimes inexplicably die, each time is located in the program in the different system () function, directly under the shell Input system () function called in the command is also
Chapter 4 inter-process communication: Pipelines
In Chapter 11th, we learned a simple way to send messages between two processes using signals. We have created a notification event that can be used to cause a response, but the transmitted
Subprocess Module Introduction
Subprocess is a tool for Python to create child processes, and in fact a fork in C is a child process, and then running exec in a child process executes another process very similar.There are many ways to create
Once, it was tortured by the system () function, because the system () function was not well understood. Simply knowing that using this function to execute a system command is not enough, it is not sufficient, its return value, the return value of
There are currently three ways to execute cmd in the python I use:
1. Using Os.system ("cmd")
The feature is that when executed, the program will play CMD on Linux execution information.
Import osos.system ("ls")
2. Using the Popen module to
There are currently three ways to execute cmd in the python I use:
1. Using Os.system ("cmd")
The feature is that when executed, the program will play CMD on Linux execution information.
Import OS
Os.system ("LS")
2. Using the Popen module to
This article describes how to use Python to call the system Shell in Linux, including reading a row of files using Python and shell, for more information about how to mount a file system, you must directly call the Shell command to complete some
Previously, we introduced a communication method between processes: Using signals, we create a notification event and send a response through it, but the transmitted information is only a signal value. Here we will introduce another way of
Once, it was tortured by the system () function, because the system () function was not well understood. Simply knowing that using this function to execute a system command is not enough, it is not sufficient, its return value, the return value of
1. Use Os.system ("cmd")
The feature is the execution of the program will play CMD on Linux implementation of the information.
Import OS
Os.system ("LS")
2. Use Popen module to generate new process
Now most people like to use Popen. The Popen
In the preceding article, we describe an inter-process communication method: Using a signal, we create a notification event, and it causes a response, but the information passed is just a signal value. Here's another way to communicate between
Subprocess is intended to replace a few other old modules or functions, such as: Os.system os.spawn* os.popen* popen2.* commands.*The simplest use of subprocess is to invoke the shell command, or to invoke the program, and to interact with
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.