changeset 1354:ed309b1fbaa4 beta

fixes issue #197 Relative paths for pidlocks
author Marcin Kuzminski <marcin@python-works.com>
date Fri, 03 Jun 2011 13:44:10 +0200
parents e354efa1f386
children bfc529377cdc
files rhodecode/lib/celerylib/__init__.py rhodecode/lib/celerylib/tasks.py rhodecode/lib/indexers/__init__.py rhodecode/lib/utils.py
diffstat 4 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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('"', "")
--- 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)\
--- 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)