Use context manager instead of acquire()/release()

This commit is contained in:
Kovid Goyal 2012-07-31 17:41:44 +05:30
parent b79fc085d2
commit cbdb05978b

View File

@ -37,12 +37,8 @@ def synchronous(tlockname):
def _synched(func):
@wraps(func)
def _synchronizer(self, *args, **kwargs):
tlock = self.__getattribute__( tlockname)
tlock.acquire()
try:
with self.__getattribute__(tlockname):
return func(self, *args, **kwargs)
finally:
tlock.release()
return _synchronizer
return _synched