[Python-ideas] Protecting finally clauses of interruptions

Yury Selivanov yselivanov.ml at gmail.com
Tue Apr 3 00:28:11 CEST 2012


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?

-
Yury



More information about the Python-ideas mailing list