[Python-ideas] Responsive signal handling

Cameron Simpson cs at zip.com.au
Tue Jun 23 08:08:45 CEST 2015


On 22Jun2015 22:42, Andrew Barnert <abarnert at yahoo.com> wrote:
>On Jun 22, 2015, at 16:00, Cameron Simpson <cs at zip.com.au> wrote:
>>
>> Perhaps a better solution here is not to keep KeyboardInterrupt special (i.e.  always going to the main thread) but to extend "raise" to accept a thread argument:
>>
>> raise blah in thread
>
>Does this need to be syntax? Why not just:
>
>    mythread.throw(blah)
>
>This could even use the same mechanism as signals in 3.6, while possibly being backportable to something hackier in a C extension module for older versions.

Indeed. I think that extending raise's syntax is a little easier on the eye, 
but the advantage is small. Certainly giving threads a throw method would 
function as well.

I was indeed hoping that signals and exceptions could be delivered the same way 
via such a mechanism, which would also allow signals to be delivered to a 
chosen thread.

Cheers,
Cameron Simpson <cs at zip.com.au>

Thus spake the master programmer: "A well written program is its own heaven;
a poorly-written program its own hell."


More information about the Python-ideas mailing list