mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-03-06 23:15:19 +01:00
Use context manager instead of acquire()/release()
This commit is contained in:
parent
b79fc085d2
commit
cbdb05978b
1 changed files with 2 additions and 6 deletions
|
|
@ -36,13 +36,9 @@ def synchronous(tlockname):
|
|||
|
||||
def _synched(func):
|
||||
@wraps(func)
|
||||
def _synchronizer(self,*args, **kwargs):
|
||||
tlock = self.__getattribute__( tlockname)
|
||||
tlock.acquire()
|
||||
try:
|
||||
def _synchronizer(self, *args, **kwargs):
|
||||
with self.__getattribute__(tlockname):
|
||||
return func(self, *args, **kwargs)
|
||||
finally:
|
||||
tlock.release()
|
||||
return _synchronizer
|
||||
return _synched
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue