Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:

> You may want to make sure the lock will be released in case of an
> exception:
> 
> def foo(self):
>     self.lock.aquire()
>     try:
>         pass # code
>     finally:
>         self.lock.release()
> 

In Python 2.5 this can also be written more succintly using the with 
statement so foo becomes:

from __future__ import with_statement
...

    def foo(self):
        with self.lock:
            pass # insert your code here


or write a decorator.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to