简体   繁体   中英

how to run several executable using python?

I have an executable under linux. I have an 8 core processor. I want to run 8 different instances of the same executable with different arguments.

I tried

     os.system("process_name args")

It does not return until the process is finished.

I want to start 8 different processes from python

If someone could help me please.

Thanks a lot

I think you're looking for the Popen objects from the subprocess module.

Note that if you want to redirect I/O to and from the process, this scenario becomes complex because the recommended way to to this is to call .communicate() which you won't be able to use if you want to manage multiple processes simultaneously. On UNIX-like systems, pipes can be passed to the select() system call so you can use the select module to perform I/O. This won't work on Windows because the select() implementation only accepts socket handles.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM