From 5d32c05eb764beed8a84dec1e91e0f8a8060899d Mon Sep 17 00:00:00 2001 From: RaNaN Date: Mon, 18 Mar 2013 19:04:48 +0100 Subject: added ReadWrite lock, render file progress on dashboard --- module/utils/__init__.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'module/utils/__init__.py') 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() -- cgit v1.2.3