subprocess.wait() not waiting for Popen process to finish (when using threads)?
You could also use check_call()
instead of Popen. check_call()
waits for the command to finish, even when shell=True
and then returns the exit code of the job.
Sadly when running your subprocess using shell=True
, wait(
) will only wait for the sh
subprocess to finish and not for the command cmd
.
I will suggest if it possible to don't use the shell=True
, if not possible you can create a process group like in this answer and use os.waitpid to wait for the process group not just the shell process.
Hope this was helpful :)
Make sure all applications your are calling have valid system return codes when they finish