sending thread exceptions (was Re: RELEASED Python 2.3.1)

Dominic oblivious at
Thu Sep 25 20:15:25 CEST 2003

>>I and Just canvassed widely at Europython, looking for people to
>>suggest more use cases, and nobody came up with anything that stood
>>up to examination beyond our basic use case of "debugging possibly
>>buggy (nonterminating) code, in cases where we just can't run the
>>possibly buggy code in the main thread and delegate a separate
>>watchdog thread to the purpose of interrupting the main one" 

One use case could be if you only want to use a limited number
of threads for some reason.

Then you could interrupt a low priority task and reassign the
thread to some more urgent task. Afterwards the old task could be 
resumed. To make this work you would have to make the code
aware of those interrupts.

While playing with the new feature I noticed that it
takes a long time (>3 seconds) until the exception is thrown.
In contrast to the possibility to interrupt the main thread
with interrupt_main which seems not to be delayed.

Besides with Pyrex it's 2-4 lines to access
PyThreadState_SetAsyncExc from Python :-)


More information about the Python-list mailing list