0

I want to create a script that run multiple python projects. Each project is blocking (meaning that every project is suppose to run forever) so this script must run each project parallel to the others. In addition I want all of these processes to close once the main shell is closed. Here is the shell code I came up with

%homepath%\Envs\env1\Scripts\pip.exe install -r python-req.txt
%homepath%\Envs\env1\Scripts\python.exe -m bot &

%homepath%\Envs\env2\Scripts\pip.exe install -r python-req.txt
%homepath%\Envs\env2\Scripts\python.exe -m base &

%homepath%\Envs\env3\Scripts\pip.exe install -r python-req.txt
%homepath%\Envs\env3\Scripts\python.exe -m caster &

I tried to use & to make to python process run asynchronously however the the script did not continue after the second line and only the first project is running.

Is there a way to run all the python processes?

oguz ismail
  • 1
  • 16
  • 47
  • 69
Yedidya kfir
  • 1,419
  • 3
  • 17
  • 32
  • It may be wise to take a look a the usage information for the `start` command, `start /?`. Removing the ampersands, and prepending each line with `start` should prevent `cmd.exe` from waiting for each command to complete before running the next! – Compo Apr 16 '20 at 18:13

1 Answers1

0

I suggest you use the subprocess Python lib.

Take a look at this example: How do I run multiple subprocesses in parallel and wait for them to finish in Python