def lockedfunc(*args, **kwargs): """ the locked function. """ where = getname(str(func)) try: rlockmanager.acquire(where) res = func(*args, **kwargs) finally: rlockmanager.release(where) return res
def __getattribute__(self, attr): where = whichmodule(1) logging.debug('locking - locking on %s' % where) rlockmanager.acquire(object) res = None try: res = super(Locked, self).__getattribute__(attr) finally: rlockmanager.release(object) return res