@@ -25,12 +25,13 @@
import os
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
from pylons import config
from vcs.utils.lazy import LazyProperty
@@ -82,23 +83,25 @@ def run_task(task, *args, **kwargs):
def __get_lockkey(func, *fargs, **fkwargs):
params = list(fargs)
params.extend(['%s-%s' % ar for ar in fkwargs.items()])
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
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
except LockHeld:
log.info('LockHeld')
return 'Task with key %s already running' % lockkey
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from celery.decorators import task
from time import mktime
from operator import itemgetter
from string import lower
@@ -97,15 +98,17 @@ def get_commits_stats(repo_name, ts_min_
log = get_commits_stats.get_logger()
except:
log = logging.getLogger(__name__)
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)
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('"', "")
co_day_auth_aggr = {}
commits_by_day_aggregate = {}
@@ -96,13 +96,13 @@ class MakeIndex(BasePasterCommand):
#======================================================================
# WHOOSH DAEMON
from rhodecode.lib.pidlock import LockHeld, DaemonLock
from rhodecode.lib.indexers.daemon import WhooshIndexingDaemon
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)\
.run(full_index=self.options.full_index)
@@ -26,12 +26,13 @@
import datetime
import paste
import beaker
from paste.script.command import Command, BadCommand
from UserDict import DictMixin
from mercurial import ui, config, hg
@@ -467,13 +468,13 @@ def create_test_index(repo_location, ful
index_location = os.path.join(repo_location, 'index')
if os.path.exists(index_location):
shutil.rmtree(index_location)
repo_location=repo_location)\
.run(full_index=full_index)
pass
Status change: