Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用 subprocess.Popen() 创建了一个运行很长时间的子进程。它从自己的线程调用,线程被阻塞直到子进程完成/返回。
我希望能够中断子进程,以便进程在我需要时终止。
有任何想法吗?
我认为您正在寻找Popen.terminate或.kill发挥作用。它们是在 python 2.6 中添加的。
Popen.terminate
.kill