threads killing other threads

Les Smithson lsmithso at NOhare.SPAM.demon.co.uk
Fri Feb 8 07:35:00 EST 2002


>>>>> "Greg" == Greg Weeks <weeks at vitus.scs.agilent.com> writes:

    Greg> I've occasionally wanted thread objects to have an exit()
    Greg> method, so that one thread could interrrupt and kill
    Greg> another.  This doesn't seem to be available, perhaps because
    Greg> POSIX threads don't support it.

    Greg> Is that correct?

    Greg> Is there some reason why threads killing threads would be
    Greg> undesirable or hard to implement?


Posix defines a pthread_cancel that lets one thread cancel another
thread. From the man page:

       Cancellation is the mechanism by which a thread can termi­
       nate  the  execution  of another thread. More precisely, a
       thread can send a cancellation request to another  thread.
       Depending  on  its  settings,  the  target thread can then
       either ignore the request, honor it immediately, or  defer
       it till it reaches a cancellation point.


I'm sure there's a good reason for Python not implementing
this. Anyone know what it is?






More information about the Python-list mailing list