I am trying to execute several batch scripts in a python loop. However, these bat scripts contain cmd /K
and thus do not "end" (due to the lack of a better word). Therefore python calls the first script and waits forever ...
Here is the pseudo code that gives an idea of ββwhat I'm trying to do:
import subprocess params = [MYSCRIPT, os.curdir] for level in range(10): subprocess.call(params)
My question is: "Is there a pythonic solution to return the console command and resume the loop?"
EDIT: now I know that you can start child processes and continue without waiting for them to return, using
Popen(params,shell=False,stdin=None,stdout=None,stderr=None,close_fds=True)
However, this would start the entire cycle almost simultaneously. Is there a way to wait for a child process to complete its task and return when it reaches cmd /K
and becomes inactive.
source share