[Python-ideas] Thread stopping

Antoine Pitrou solipsis at pitrou.net
Sat Mar 31 01:04:13 CEST 2012


On Fri, 30 Mar 2012 21:14:43 +1100
Steven D'Aprano <steve at pearwood.info> wrote:
> Matt Joiner wrote:
> > Wouldn't it be better to raise a SystemExit in a thread you want
> > interrupted?
> 
> I must admit I'm rather confused about this suggestion. Do you mean the thread 
> itself should raise SystemExit? If so, why not just exit the normal way?
> 
> If you mean the main thread somehow injects a SystemExit in another thread, 
> how would you do that? Perhaps I'm missing something obvious, but I don't know 
> how to do that.

http://docs.python.org/dev/c-api/init.html#PyThreadState_SetAsyncExc

Regards

Antoine.





More information about the Python-ideas mailing list