Kill a thread in Python

Roger Binns rogerb at rogerbinns.com
Tue May 4 01:34:14 EDT 2004


C. Barnes wrote:
> However, if your code hangs at a lower level than
> Python, then the
> thread will not actually be killed until the next
> Python statement is
> executed.

That is the usual case for me.  My threads are blocked in calls
to read, accept or Queue.get().

> Consider bugging the Python folks, until they give us
> a thread kill
> method.  The code has already been written:
>
> http://mail.python.org/pipermail/python-list/2003-February/148999.html

Looking through that patch I couldn't tell if it could
terminate a thread that was in native code.  It seemed
to cause the kill to happen in the next bit of Python
bytecode interpretted.

Incidentally Java does have a thread kill method although
it is strongly recommended against using.

Roger





More information about the Python-list mailing list