[Python-Dev] Re: [Python-checkins] CVS: python/nondist/peps pep-0042.txt,1.43,1.44
Guido van Rossum
Tue, 14 Nov 2000 07:06:48 -0500
> On Mon, 13 Nov 2000, Guido van Rossum wrote:
> > + - Killing a thread from another thread. Or maybe sending a
> > + signal. Or maybe raising an asynchronous exception.
> > +
> > + http://sourceforge.net/bugs/?func=detailbug&bug_id=121115&group_id=5470
> In general, killing threads in considered a bad idea. It is usually much
> better to design the application properly, and being aware that a thread
> doing nothing is not that big a deal.
Sorry. I agree 99% (see the referenced thread). But this keeps
coming up as a feature request, so I figured that there should be
*something* we could offer -- if only some support library calls to
make implementing this common pattern smooth.
For that 1%, I believe that raising an asynchronous exception takes away
*most* of the objections against killing threads -- it gives the
thread control over recovery, since exceptions are to be expected
Also note that in a long-running server, losing a thread every once in
a while means leaking a lot of memory! So (in that case) the
application design cannot afford to just "park" unproductive threads
forever -- it must contain a robust way of recovering their resources.
--Guido van Rossum (home page: http://www.python.org/~guido/)