Changeset - 9bedaa073c23
[Not reviewed]
default
0 2 0
Marcin Kuzminski - 15 years ago 2010-09-28 22:07:55
marcin@python-works.com
fixed lockdecrator to return executed function data
removed print
2 files changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
pylons_app/controllers/summary.py
Show inline comments
 
@@ -86,20 +86,19 @@ class SummaryController(BaseController):
 
            .scalar()
 
        
 
        
 
        if stats and stats.languages:
 
            lang_stats = json.loads(stats.languages)
 
            c.commit_data = stats.commit_activity
 
            c.overview_data = stats.commit_activity_combined
 
            c.trending_languages = json.dumps(OrderedDict(
 
                                       sorted(lang_stats.items(), reverse=True,
 
                                            key=lambda k: k[1])[:2]
 
                                        )
 
                                    )
 
            print c.trending_languages
 
        else:
 
            c.commit_data = json.dumps({})
 
            c.overview_data = json.dumps([[ts_min_y, 0], [ts_max_y, 0] ])
 
            c.trending_languages = json.dumps({})
 
        
 
        return render('summary/summary.html')
 

	
pylons_app/lib/celerylib/__init__.py
Show inline comments
 
@@ -33,26 +33,27 @@ def run_task(task, *args, **kwargs):
 

	
 
def locked_task(func):
 
    def __wrapper(func, *fargs, **fkwargs):
 
        params = list(fargs)
 
        params.extend(['%s-%s' % ar for ar in fkwargs.items()])
 
            
 
        lockkey = 'task_%s' % \
 
            md5(str(func.__name__) + '-' + \
 
                '-'.join(map(str, params))).hexdigest()
 
        log.info('running task with lockkey %s', lockkey)
 
        try:
 
            l = DaemonLock(lockkey)
 
            func(*fargs, **fkwargs)
 
            ret = func(*fargs, **fkwargs)
 
            l.release()
 
            return ret
 
        except LockHeld:
 
            log.info('LockHeld')
 
            return 'Task with key %s already running' % lockkey   
 

	
 
    return decorator(__wrapper, func)      
 
            
 

	
 
        
 
        
 
    
 
    
 
    
0 comments (0 inline, 0 general)