[Python-ideas] Protecting finally clauses of interruptions

Yury Selivanov yselivanov.ml at gmail.com
Tue Apr 3 01:04:22 CEST 2012

On 2012-04-02, at 6:33 PM, Paul Colomiets wrote:
>> How's that going to work for tons of existing code?
> It isn't. But it doesn't break code any more than it
> already is. Your proposal doesn't solve any problems
> with existing code too.
> But anyway I don't propose any new ways to interrupt
> code I only propose a way to inform trampoline when it's
> unsafe to interrupt code.

Well, if we're thinking only about interrupting coroutines 
(not threads), then it's going to work, yes.

My initial desire to use a special exception for the purpose, 
was because of:

- it's easier to throw exception in the thread (the C-API
function already exists, and we need to think about 
consequences of using it)

- PyPy disables the JIT when working with frames (if I recall
correctly).  That's why I wanted 'f_in_finally' to be an
implementation detail of CPython, hidden from the user code.  
Perhaps PyPy could implement the handling of our special 
exception in a more efficient way, without the side-effect 
of disabling the JIT.

What do you think?


More information about the Python-ideas mailing list