threads killing other threads

Tim Peters tim.one at comcast.net
Fri Feb 8 23:31:55 EST 2002


[Les Smithson]
> But doesn't pthread_testcancel allow cooperative threads to be
> canceled?

Yes.

> This is the portable equivalent to the thread signaling scheme
> described earlier.

It's only portable among platforms with pthreads implementations recent
enough to include it.  The thread facilities Python exposes are much more
portable than that.

> It also gives the canceled thread a chance to clean itself up before
> exiting.

Yes, provided you expose more and more of pthread-specific functionality to
get at all this stuff.

> Not ideal, but better than nothing.

I'm afraid the truly portable part of it remains nothing.  Someone may care
to write a pthreads-specific extension to Python's threading facilities,
though.  Note that what people actually ask for is a way to *force* another
thread to terminate (even if it's, e.g., stuck in a blocking I/O call), so
the audience for this kind of gimmick gets slashed repeatedly each time
reality objects <wink>.

don't-use-threads-when-you-want-processes-ly y'rs  - tim





More information about the Python-list mailing list