summaryrefslogtreecommitdiffstats
path: root/module/utils
diff options
context:
space:
mode:
Diffstat (limited to 'module/utils')
-rw-r--r--module/utils/__init__.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/module/utils/__init__.py b/module/utils/__init__.py
index 4692c59cb..8f7ed6231 100644
--- a/module/utils/__init__.py
+++ b/module/utils/__init__.py
@@ -125,11 +125,21 @@ def parseFileSize(string, unit=None): #returns bytes
def lock(func):
- def new(*args):
+ def new(*args, **kwargs):
#print "Handler: %s args: %s" % (func,args[1:])
args[0].lock.acquire()
try:
- return func(*args)
+ return func(*args, **kwargs)
+ finally:
+ args[0].lock.release()
+
+ return new
+
+def read_lock(func):
+ def new(*args, **kwargs):
+ args[0].lock.acquire(shared=True)
+ try:
+ return func(*args, **kwargs)
finally:
args[0].lock.release()