开发者

How do I execute two programs from python at the same time?

开发者 https://www.devze.com 2023-03-18 08:41 出处:网络
开发者_开发技巧This post explains how to launch a single external program from Python How shall I launch multipal programs(or threads) at the same time ?

开发者_开发技巧This post explains how to launch a single external program from Python How shall I launch multipal programs(or threads) at the same time ?

My intended application is a video slide show. I want to launch a image sequence player and a music player at the same time

Thanks in advance


subprocess.Popen doesn't block unless you explicitly ask it to by calling communicate on the returned object, so you can call it more than once to start more than one process.

If you do need to communicate with both sub-processes simultaneously (read their STDOUT, for instance), then invoke subprocess.Popen in separate threads. Each thread can manage a sub-process and communicate with it. Naturally, this leaves you to do all the synchronization but that highly depends on your specific application.

0

精彩评论

暂无评论...
验证码 换一张
取 消