##// END OF EJS Templates
fixes issue #197 Relative paths for pidlocks
marcink -
r1354:ed309b1f beta
parent child Browse files
Show More
@@ -28,6 +28,7 b' import sys'
28 import socket
28 import socket
29 import traceback
29 import traceback
30 import logging
30 import logging
31 from os.path import dirname as dn, join as jn
31
32
32 from hashlib import md5
33 from hashlib import md5
33 from decorator import decorator
34 from decorator import decorator
@@ -85,7 +86,7 b' def __get_lockkey(func, *fargs, **fkwarg'
85
86
86 func_name = str(func.__name__) if hasattr(func, '__name__') else str(func)
87 func_name = str(func.__name__) if hasattr(func, '__name__') else str(func)
87
88
88 lockkey = 'task_%s' % \
89 lockkey = 'task_%s.lock' % \
89 md5(func_name + '-' + '-'.join(map(str, params))).hexdigest()
90 md5(func_name + '-' + '-'.join(map(str, params))).hexdigest()
90 return lockkey
91 return lockkey
91
92
@@ -93,9 +94,11 b' def __get_lockkey(func, *fargs, **fkwarg'
93 def locked_task(func):
94 def locked_task(func):
94 def __wrapper(func, *fargs, **fkwargs):
95 def __wrapper(func, *fargs, **fkwargs):
95 lockkey = __get_lockkey(func, *fargs, **fkwargs)
96 lockkey = __get_lockkey(func, *fargs, **fkwargs)
97 lockkey_path = dn(dn(dn(os.path.abspath(__file__))))
98
96 log.info('running task with lockkey %s', lockkey)
99 log.info('running task with lockkey %s', lockkey)
97 try:
100 try:
98 l = DaemonLock(lockkey)
101 l = DaemonLock(jn(lockkey_path, lockkey))
99 ret = func(*fargs, **fkwargs)
102 ret = func(*fargs, **fkwargs)
100 l.release()
103 l.release()
101 return ret
104 return ret
@@ -28,6 +28,7 b' from celery.decorators import task'
28 import os
28 import os
29 import traceback
29 import traceback
30 import logging
30 import logging
31 from os.path import dirname as dn, join as jn
31
32
32 from time import mktime
33 from time import mktime
33 from operator import itemgetter
34 from operator import itemgetter
@@ -100,9 +101,11 b' def get_commits_stats(repo_name, ts_min_'
100
101
101 lockkey = __get_lockkey('get_commits_stats', repo_name, ts_min_y,
102 lockkey = __get_lockkey('get_commits_stats', repo_name, ts_min_y,
102 ts_max_y)
103 ts_max_y)
104 lockkey_path = dn(dn(dn(dn(os.path.abspath(__file__)))))
105 print jn(lockkey_path, lockkey)
103 log.info('running task with lockkey %s', lockkey)
106 log.info('running task with lockkey %s', lockkey)
104 try:
107 try:
105 lock = DaemonLock(lockkey)
108 lock = l = DaemonLock(jn(lockkey_path, lockkey))
106
109
107 #for js data compatibilty cleans the key for person from '
110 #for js data compatibilty cleans the key for person from '
108 akc = lambda k: person(k).replace('"', "")
111 akc = lambda k: person(k).replace('"', "")
@@ -99,7 +99,7 b' class MakeIndex(BasePasterCommand):'
99 from rhodecode.lib.pidlock import LockHeld, DaemonLock
99 from rhodecode.lib.pidlock import LockHeld, DaemonLock
100 from rhodecode.lib.indexers.daemon import WhooshIndexingDaemon
100 from rhodecode.lib.indexers.daemon import WhooshIndexingDaemon
101 try:
101 try:
102 l = DaemonLock()
102 l = DaemonLock(file=jn(dn(dn(index_location)), 'make_index.lock'))
103 WhooshIndexingDaemon(index_location=index_location,
103 WhooshIndexingDaemon(index_location=index_location,
104 repo_location=repo_location,
104 repo_location=repo_location,
105 repo_list=repo_list)\
105 repo_list=repo_list)\
@@ -29,6 +29,7 b' import datetime'
29 import traceback
29 import traceback
30 import paste
30 import paste
31 import beaker
31 import beaker
32 from os.path import dirname as dn, join as jn
32
33
33 from paste.script.command import Command, BadCommand
34 from paste.script.command import Command, BadCommand
34
35
@@ -470,7 +471,7 b' def create_test_index(repo_location, ful'
470 shutil.rmtree(index_location)
471 shutil.rmtree(index_location)
471
472
472 try:
473 try:
473 l = DaemonLock()
474 l = DaemonLock(file=jn(dn(dn(index_location)), 'make_index.lock'))
474 WhooshIndexingDaemon(index_location=index_location,
475 WhooshIndexingDaemon(index_location=index_location,
475 repo_location=repo_location)\
476 repo_location=repo_location)\
476 .run(full_index=full_index)
477 .run(full_index=full_index)
General Comments 0
You need to be logged in to leave comments. Login now