summaryrefslogtreecommitdiffstats
path: root/module/utils/__init__.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-18 19:04:48 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-18 19:04:48 +0100
commit5d32c05eb764beed8a84dec1e91e0f8a8060899d (patch)
treed4d71b48908c097bde2a3ec9c7c2b80d54b5eccd /module/utils/__init__.py
parentrender download progress (diff)
downloadpyload-5d32c05eb764beed8a84dec1e91e0f8a8060899d.tar.xz
added ReadWrite lock, render file progress on dashboard
Diffstat (limited to 'module/utils/__init__.py')
-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()