Killing threads (was Re: Cancel or timeout a long running regular expression)

Martin v. Loewis martin at v.loewis.de
Wed Sep 21 07:41:50 CEST 2011


> Is it just that nobody's implemented it, or is there a good reason for
> avoiding offering this sort of thing?

I've been considering to implement killing threads several times for the
last 15 years (I think about it once every year), and every time
I give up because it's too complex and just not implementable.

To start with, a simple flag in the thread won't do any good. It will
not cancel blocking system calls, so people will complain that the
threads they meant to cancel continue to run forever. Instead, you
have to use some facility to interrupt blocking system calls. You
then have to convince callers of those blocking system calls not to
retry when they see that the first attempt to call it was interrupted.
And so on.

Regards,
Martin



More information about the Python-list mailing list