【发布时间】:2021-09-01 13:39:15
【问题描述】:
我正在使用子进程运行两个 python 脚本,其中一个仍在运行。
import subprocess
subprocess.run("python3 script_with_loop.py & python3 scrip_with_io.py", shell=True)
script_with_loop 仍然在后台运行。
如果其中一个脚本死亡,如何杀死两个脚本?
【问题讨论】:
-
"如果其中一个死了",如果认为更正确的说法是其中之一
finishes its task或is done -
所以你想在
script_with_io完成后杀死script_with_loop? -
@alexzander 是的,这是真的......线程解决方案和使用下面的语句对我有用。
标签: python python-3.x subprocess