Changeset - ed309b1fbaa4
[Not reviewed]
beta
0 4 0
Marcin Kuzminski - 14 years ago 2011-06-03 13:44:10
marcin@python-works.com
fixes issue #197 Relative paths for pidlocks
4 files changed with 12 insertions and 5 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/celerylib/__init__.py
Show inline comments
 
@@ -28,6 +28,7 @@ import sys
 
import socket
 
import traceback
 
import logging
 
from os.path import dirname as dn, join as jn
 

	
 
from hashlib import md5
 
from decorator import decorator
 
@@ -85,7 +86,7 @@ def __get_lockkey(func, *fargs, **fkwarg
 

	
 
    func_name = str(func.__name__) if hasattr(func, '__name__') else str(func)
 

	
 
    lockkey = 'task_%s' % \
 
    lockkey = 'task_%s.lock' % \
 
        md5(func_name + '-' + '-'.join(map(str, params))).hexdigest()
 
    return lockkey
 

	
 
@@ -93,9 +94,11 @@ def __get_lockkey(func, *fargs, **fkwarg
 
def locked_task(func):
 
    def __wrapper(func, *fargs, **fkwargs):
 
        lockkey = __get_lockkey(func, *fargs, **fkwargs)
 
        lockkey_path = dn(dn(dn(os.path.abspath(__file__))))
 

	
 
        log.info('running task with lockkey %s', lockkey)
 
        try:
 
            l = DaemonLock(lockkey)
 
            l = DaemonLock(jn(lockkey_path, lockkey))
 
            ret = func(*fargs, **fkwargs)
 
            l.release()
 
            return ret
rhodecode/lib/celerylib/tasks.py
Show inline comments
 
@@ -28,6 +28,7 @@ from celery.decorators import task
 
import os
 
import traceback
 
import logging
 
from os.path import dirname as dn, join as jn
 

	
 
from time import mktime
 
from operator import itemgetter
 
@@ -100,9 +101,11 @@ def get_commits_stats(repo_name, ts_min_
 

	
 
    lockkey = __get_lockkey('get_commits_stats', repo_name, ts_min_y,
 
                            ts_max_y)
 
    lockkey_path = dn(dn(dn(dn(os.path.abspath(__file__)))))
 
    print jn(lockkey_path, lockkey)
 
    log.info('running task with lockkey %s', lockkey)
 
    try:
 
        lock = DaemonLock(lockkey)
 
        lock = l = DaemonLock(jn(lockkey_path, lockkey))
 

	
 
        #for js data compatibilty cleans the key for person from '
 
        akc = lambda k: person(k).replace('"', "")
rhodecode/lib/indexers/__init__.py
Show inline comments
 
@@ -99,7 +99,7 @@ class MakeIndex(BasePasterCommand):
 
        from rhodecode.lib.pidlock import LockHeld, DaemonLock
 
        from rhodecode.lib.indexers.daemon import WhooshIndexingDaemon
 
        try:
 
            l = DaemonLock()
 
            l = DaemonLock(file=jn(dn(dn(index_location)), 'make_index.lock'))
 
            WhooshIndexingDaemon(index_location=index_location,
 
                                 repo_location=repo_location,
 
                                 repo_list=repo_list)\
rhodecode/lib/utils.py
Show inline comments
 
@@ -29,6 +29,7 @@ import datetime
 
import traceback
 
import paste
 
import beaker
 
from os.path import dirname as dn, join as jn
 

	
 
from paste.script.command import Command, BadCommand
 

	
 
@@ -470,7 +471,7 @@ def create_test_index(repo_location, ful
 
        shutil.rmtree(index_location)
 

	
 
    try:
 
        l = DaemonLock()
 
        l = DaemonLock(file=jn(dn(dn(index_location)), 'make_index.lock'))
 
        WhooshIndexingDaemon(index_location=index_location,
 
                             repo_location=repo_location)\
 
            .run(full_index=full_index)
0 comments (0 inline, 0 general)