[Python-Dev] Where to put the interrupt module?

Neal Norwitz neal@metaslash.com
Fri, 13 Jun 2003 09:50:22 -0400


On Fri, Jun 13, 2003 at 09:11:47AM -0400, Guido van Rossum wrote:
> 
> There's also a race condition in the language design that would need
> to be fixed ...
> 
>   lock.acquire()
>   try:
>       ...critical section code...
>   finally:
>       lock.release()
> 
> I've seen a proposal (I think it was in a paper presented at the
> second Little Languages conference at MIT, earlier this year) of a
> syntactic extension that could be used:
> 
>   initially:
>       lock.acquire()
>   try:
>       ...critical section code...
>   finally:
>       lock.release()

Part of the idea (or at least my idea) behind adding the do/with
statement which was discussed a while ago was to fix this problem.

        with lock:
            ... critical section ...

would ensure that lock.release() is called properly.

Neal