Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 39d019a

Browse files
committed
use functools.wraps for synchronized decorator
1 parent af2b2e4 commit 39d019a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

java2python/mod/include/sync.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
from functools import wraps
12
from threading import RLock
23

34
def lock_for_object(obj, locks={}):
45
return locks.setdefault(id(obj), RLock())
56

67
def synchronized(call):
78
assert call.__code__.co_varnames[0] in {'self', 'cls'}
9+
@wraps(call)
810
def inner(*args, **kwds):
911
with lock_for_object(args[0]):
1012
return call(*args, **kwds)

0 commit comments

Comments
 (0)