Multi-process programming 2

========== Details of python development technology

The child process from
os.system will return control to python after the end; os.exec will take over the python process, and will not return control to python. Will exit.

exit can exit the process in a gentle way;
abort will violently exit the process
/////////////////////
subprocess as an advanced module for process management , providing one class and two functions To manage the process.
The shell in subprocess.popen: When the shell is false, popen will call os.execvp to execute the corresponding program. But when the shell is true, if the command is a string, popen directly calls the system shell to execute the specified program.

If the command is a sequence, the first item is the command string, and the other items are additional parameters of the command.

If you need to wait for the end of the child process, you can use the wait () function of the popen class.
If you need to manage the input and output of the child process, you can change the stdin, stdout, and stderr of the popen class.

After outputting the result, stdout becomes a readable output object

  Because the data is cached in memory, when the amount of data is large, do not use communicate

 subprocess's call and check_all is a simplification of popen, call can directly generate a subprocess, and wait for the subprocess to end. The difference between check_all and call is that if the return value is not 0, the exception CallProcessError is triggered, and the return value of the exception object has a return value

Guess you like

Origin www.cnblogs.com/testzcy/p/12756207.html
Recommended