Skip to content

Commit a33c28c

Browse files
committed
Add back synchronization util
1 parent 8f30db7 commit a33c28c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import functools
2+
import threading
3+
4+
5+
def synchronized(wrapped):
6+
"""The missing @synchronized decorator
7+
8+
https://git.io/vydTA"""
9+
_lock = threading.RLock()
10+
11+
@functools.wraps(wrapped)
12+
def _wrapper(*args, **kwargs):
13+
with _lock:
14+
return wrapped(*args, **kwargs)
15+
return _wrapper

0 commit comments

Comments
 (0)