McBear Holden
McBear Holden

Reputation: 5901

How do I execute two programs from python 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

Upvotes: 0

Views: 2650

Answers (1)

Eli Bendersky
Eli Bendersky

Reputation: 273406

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.

Upvotes: 5

Related Questions