# HG changeset patch # User Marcin Kuzminski # Date 2011-06-03 11:44:10 # Node ID ed309b1fbaa420bdd96902f32d05a2baadd753e8 # Parent e354efa1f386575bdf6a475a4e19b78de0cf21eb fixes issue #197 Relative paths for pidlocks diff --git a/rhodecode/lib/celerylib/__init__.py b/rhodecode/lib/celerylib/__init__.py --- a/rhodecode/lib/celerylib/__init__.py +++ b/rhodecode/lib/celerylib/__init__.py @@ -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 diff --git a/rhodecode/lib/celerylib/tasks.py b/rhodecode/lib/celerylib/tasks.py --- a/rhodecode/lib/celerylib/tasks.py +++ b/rhodecode/lib/celerylib/tasks.py @@ -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('"', "") diff --git a/rhodecode/lib/indexers/__init__.py b/rhodecode/lib/indexers/__init__.py --- a/rhodecode/lib/indexers/__init__.py +++ b/rhodecode/lib/indexers/__init__.py @@ -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)\ diff --git a/rhodecode/lib/utils.py b/rhodecode/lib/utils.py --- a/rhodecode/lib/utils.py +++ b/rhodecode/lib/utils.py @@ -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)