How to force a thread to stop

Paul Rubin http
Mon Jul 24 21:45:36 EDT 2006


"Carl J. Van Arsdall" <cvanarsdall at mvista.com> writes:
> > Communications through Queue.Queue objects can help. But if you
> > research the history of this design decision in the language you
> > should discover there are fairly sound rasons for not allowing
> > arbitrary "threadicide".
> >
> Right, I'm wondering if there was a way to make an interrupt driven
> communication mechanism for threads?  Example: thread receives a
> message, stops everything, and processes the message. --

There is in fact some under-the-covers mechanism in CPython (i.e.
one you can call from C extensions but not from Python code) to
raise exceptions in other threads.  I've forgotten the details.
There has been discussion at various times about how to expose
something like that to Python code, but it's been inconclusive.  E.g.:

http://sf.net/tracker/?func=detail&atid=105470&aid=502236&group_id=5470 



More information about the Python-list mailing list