# HG changeset patch # User Marcin Kuzminski # Date 1307101450 -7200 # Node ID ed309b1fbaa420bdd96902f32d05a2baadd753e8 # Parent e354efa1f386575bdf6a475a4e19b78de0cf21eb fixes issue #197 Relative paths for pidlocks diff -r e354efa1f386 -r ed309b1fbaa4 rhodecode/lib/celerylib/__init__.py --- a/rhodecode/lib/celerylib/__init__.py Thu Jun 02 15:25:28 2011 +0200 +++ b/rhodecode/lib/celerylib/__init__.py Fri Jun 03 13:44:10 2011 +0200 @@ -28,6 +28,7 @@ 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 @@ 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 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 -r e354efa1f386 -r ed309b1fbaa4 rhodecode/lib/celerylib/tasks.py --- a/rhodecode/lib/celerylib/tasks.py Thu Jun 02 15:25:28 2011 +0200 +++ b/rhodecode/lib/celerylib/tasks.py Fri Jun 03 13:44:10 2011 +0200 @@ -28,6 +28,7 @@ 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 @@ 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 -r e354efa1f386 -r ed309b1fbaa4 rhodecode/lib/indexers/__init__.py --- a/rhodecode/lib/indexers/__init__.py Thu Jun 02 15:25:28 2011 +0200 +++ b/rhodecode/lib/indexers/__init__.py Fri Jun 03 13:44:10 2011 +0200 @@ -99,7 +99,7 @@ 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 -r e354efa1f386 -r ed309b1fbaa4 rhodecode/lib/utils.py --- a/rhodecode/lib/utils.py Thu Jun 02 15:25:28 2011 +0200 +++ b/rhodecode/lib/utils.py Fri Jun 03 13:44:10 2011 +0200 @@ -29,6 +29,7 @@ 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 @@ 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)