简体   繁体   English

停止长时间运行的子进程

[英]Stopping a Long-Running Subprocess

I create a subprocess using subprocess.Popen() that runs for a long time. 我使用运行了很长时间的subprocess.Popen()创建一个子进程。 It is called from its own thread, and the thread is blocked until the subprocess completes/returns. 它从自己的线程调用,线程被阻塞,直到子进程完成/返回。

I want to be able to interrupt the subprocess so the process terminates when I want. 我希望能够中断子进程,以便在我想要的时候终止进程。

Any ideas? 有任何想法吗?

I think you're looking for Popen.terminate or .kill function. 我想你正在寻找Popen.terminate.kill功能。 They were added in python 2.6. 它们是在python 2.6中添加的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM