subprocess.wait() not waiting for Popen process to finish (when using threads)?

后端 未结 4 1089
悲&欢浪女
悲&欢浪女 2020-12-03 14:12

I am experiencing some problems when using subprocess.Popen() to spawn several instances of the same application from my python script using threads to have the

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-03 14:37

    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 :)

提交回复
热议问题