Best way to handle exceptions with try/finally
Maxim Sloyko
m.sloyko at gmail.com
Wed May 24 03:55:32 EDT 2006
I guess the following standard method will help :
class MyLocker(object):
def __init__(self, lock):
self.lock = lock
self.lock.acquire()
def __del__(self):
self.lock.release()
Then whenever you need to acquire a lock:
templock = MyLocker(self.__mutex)
del templock # will release the lock (provided you didn't create an
extra link to this object)
More information about the Python-list
mailing list