thread help

Roger Binns rogerb at rogerbinns.com
Wed Jun 16 04:07:23 EDT 2004


Peter Hansen wrote:
> Sounds like you can't eat your cake and have it, too.  If
> you _could_ interrupt threads**, wouldn't that mean "the worker
> threads just get abruptly stopped in the middle of what they
> were doing"?

I meant in the same way that can in Java.  In that case an
InterruptedException is thrown which the thread can catch
and do whatever it wants with.

As an example at the moment, socket.accept is a blocking
call and if a thread is executing that there is no way
of stopping it.

This would make shutdown and reconfigurations possible.
For example you could interrupt all relevant threads
and they could check a variable to see if they should
shutdown, bind to a different port, abandon the current
work item etc.

Roger





More information about the Python-list mailing list