Minor update

This commit is contained in:
Miroslav Stampar
2026-01-09 17:01:00 +01:00
parent 7bc3741a48
commit bc0d2a11a3
4 changed files with 16 additions and 4 deletions

View File

@@ -103,6 +103,17 @@ def stackedmethod(f):
return _
def lockedmethod(f):
"""
Decorates a function or method with a reentrant lock (only one thread can execute the function at a time)
>>> @lockedmethod
... def recursive_count(n):
... if n <= 0: return 0
... return n + recursive_count(n - 1)
>>> recursive_count(5)
15
"""
lock = threading.RLock()
@functools.wraps(f)