如何使用python运行几个可执行文件? [英] how to run several executable using python?

查看:57
本文介绍了如何使用python运行几个可执行文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Linux下有一个可执行文件.我有一个8核处理器.我想用不同的参数运行同一可执行文件的8个不同实例.

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.

我尝试了

     os.system("process_name args")

在处理完成之前它不会返回.

It does not return until the process is finished.

我想从python启动8个不同的进程

I want to start 8 different processes from python

如果有人可以帮助我,请

If someone could help me please.

非常感谢

推荐答案

我认为您正在从Popen对象. html> subprocess 模块.

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

请注意,如果您想在该过程之间来回重定向I/O,这种情况将变得很复杂,因为推荐的方法是调用 select 执行I/O的模块.这在Windows上不起作用,因为select()实现仅接受套接字句柄.

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.

这篇关于如何使用python运行几个可执行文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆