python子进程能再开进程吗_Python可以杀死继续运行的子进程吗?

Suppose we spawn a child process with Popen. I''m thinking of an

executable file, like a compiled C program.

Suppose it is supposed to run for one minute, but it just keeps going

and going. Does Python have any way to kill it?

This is not hypothetical; I''m doing it now, and it''s working pretty

well, but I would like to be able to handle this run-on condition. I''m

using Windows 2000, but I want my program to be portable to linux.

Thanks

Mitchell Timin

--

I''m proud of http://ANNEvolve.sourceforge.net. If you want to write software,

or articles, or do testing or research for ANNEvolve, let me know.

Humans may know that my email address is: (but remove the 3 digit number)

zenguy at shaw666 dot ca

解决方案I. Myself wrote:Suppose we spawn a child process with Popen. I''m thinking of an

executable file, like a compiled C program.

Suppose it is supposed to run for one minute, but it just keeps going

and going. Does Python have any way to kill it?

This is not hypothetical; I''m doing it now, and it''s working pretty

well, but I would like to be able to handle this run-on condition. I''m

using Windows 2000, but I want my program to be portable to linux.

On linux it''s pretty easy to do, just setup alarm signal. On windows

it''s not so trivial to the point you cannot do it using python.org

distribution, you will need to poke in low level C API using win32

extensions or ctypes. AFAIK twisted package

has some code to help you. Also take a look at buildbot sources

that uses twisted. Buildbot has the same

problem as you have, it needs to kill run away or non-responding

processes.

Serge Orlov wrote:I. Myself wrote:

Suppose we spawn a child process with Popen. I''m thinking of an

executable file, like a compiled C program.

Suppose it is supposed to run for one minute, but it just keeps going

and going. Does Python have any way to kill it?

This is not hypothetical; I''m doing it now, and it''s working pretty

well, but I would like to be able to handle this run-on condition. I''m

using Windows 2000, but I want my program to be portable to linux.

On linux it''s pretty easy to do, just setup alarm signal. On windows

it''s not so trivial to the point you cannot do it using python.org

distribution, you will need to poke in low level C API using win32

extensions or ctypes. AFAIK twisted package

has some code to help you. Also take a look at buildbot sources

that uses twisted. Buildbot has the same

problem as you have, it needs to kill run away or non-responding

processes.

That is bad news. Thanks anyway; bad news is better than no news.

Mitchell Timin

--

I''m proud of http://ANNEvolve.sourceforge.net. If you want to write software,

or articles, or do testing or research for ANNEvolve, let me know.

Humans may know that my email address is: (but remove the 3 digit number)

zenguy at shaw666 dot ca

I. Myself wrote:Serge Orlov wrote:

I. Myself wrote:

Suppose we spawn a child process with Popen. I''m thinking of an

executable file, like a compiled C program.

Suppose it is supposed to run for one minute, but it just keeps going

and going. Does Python have any way to kill it?

This is not hypothetical; I''m doing it now, and it''s working pretty

well, but I would like to be able to handle this run-on condition. I''m

using Windows 2000, but I want my program to be portable to linux.

On linux it''s pretty easy to do, just setup alarm signal. On windows

it''s not so trivial to the point you cannot do it using python.org

distribution, you will need to poke in low level C API using win32

extensions or ctypes. AFAIK twisted package

has some code to help you. Also take a look at buildbot sources

that uses twisted. Buildbot has the same

problem as you have, it needs to kill run away or non-responding

processes.

That is bad news. Thanks anyway; bad news is better than no news.

Note, however, taht ctypes is planned to be a part of the 2.5

distribution, so while there may not be a platform-independent way to

achieve your goals you will at leats be able to do so without external

extensions.

regards

Steve

--

Steve Holden +44 150 684 7255 +1 800 494 3119

Holden Web LLC/Ltd http://www.holdenweb.com

Love me, love my blog http://holdenweb.blogspot.com

Recent Ramblings http://del.icio.us/steve.holden

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值