[Python-ideas] Protecting finally clauses of interruptions

Paul Colomiets paul at colomiets.name
Tue Apr 3 00:33:02 CEST 2012


Hi Yury,

On Tue, Apr 3, 2012 at 1:28 AM, Yury Selivanov <yselivanov.ml at gmail.com> wrote:
> On 2012-04-02, at 6:24 PM, Paul Colomiets wrote:
>>> I still don't get how exactly do you propose to handle sudden thread
>>> interruption in your own example:
>>>
>>> l.lock()
>>> # (!) the thread may be interrupted at this point
>>> try:
>>>   ...
>>> finally:
>>>   l.unlock()
>>>
>>> You don't have a 'with' statement here.
>>>
>>
>> By wrapping lock into a context manager.
>
> 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.

-- 
Paul



More information about the Python-ideas mailing list