We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3f2407d commit af2b2e4Copy full SHA for af2b2e4
java2python/mod/include/sync.py
@@ -1,12 +1,11 @@
1
from threading import RLock
2
3
-_locks = {}
4
-def lock_for_object(obj, locks=_locks):
+def lock_for_object(obj, locks={}):
5
return locks.setdefault(id(obj), RLock())
6
7
-
8
def synchronized(call):
+ assert call.__code__.co_varnames[0] in {'self', 'cls'}
9
def inner(*args, **kwds):
10
- with lock_for_object(call):
+ with lock_for_object(args[0]):
11
return call(*args, **kwds)
12
return inner
0 commit comments