diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-03-18 19:04:48 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-03-18 19:04:48 +0100 |
commit | 5d32c05eb764beed8a84dec1e91e0f8a8060899d (patch) | |
tree | d4d71b48908c097bde2a3ec9c7c2b80d54b5eccd /module/utils/__init__.py | |
parent | render download progress (diff) | |
download | pyload-5d32c05eb764beed8a84dec1e91e0f8a8060899d.tar.xz |
added ReadWrite lock, render file progress on dashboard
Diffstat (limited to 'module/utils/__init__.py')
-rw-r--r-- | module/utils/__init__.py | 14 |
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() |