Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 920
Shan Avatar asked Mar 15 '12 16:03

Shan


1 Answers

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.

like image 188
André Caron Avatar answered Oct 03 '22 08:10

André Caron