[Python-ideas] Protecting finally clauses of interruptions

Paul Colomiets paul at colomiets.name
Thu Apr 5 00:45:42 CEST 2012

Hi Greg,

On Thu, Apr 5, 2012 at 1:18 AM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Paul Colomiets wrote:
>> Do you mean put callback in a frame, which get
>> executed at next bytecode just like signal handler,
>> except it waits until finally clause is executed?
> It wouldn't be in each frame -- probably it would just
> be a global hook that gets called whenever a finally-counter
> anywhere gets decremented from 1 to 0. It would be passed
> the relevant frame so it could decide what to do from
> there.

It's similar to sys.settrace() except it only executed when
finally counter decremented to 0, right?
Flag `f_in_finally` is still there, right?

It solves my use case well.

Yury, is it ok if l'll start a PEP with this idea, and when
it will have some support (or be rejected), you'll come
up with thread interruption proposal?


More information about the Python-ideas mailing list