mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Use context manager instead of acquire()/release()
This commit is contained in:
parent
b79fc085d2
commit
cbdb05978b
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user