##// END OF EJS Templates
caches: added debug and timings
super-admin -
r4733:3c68f6b7 stable
parent child Browse files
Show More
@@ -300,7 +300,6 b' class BaseRedisBackend(redis_backend.Red'
300 def get_mutex(self, key):
300 def get_mutex(self, key):
301 if self.distributed_lock:
301 if self.distributed_lock:
302 lock_key = redis_backend.u('_lock_{0}').format(key)
302 lock_key = redis_backend.u('_lock_{0}').format(key)
303 log.debug('Trying to acquire Redis lock for key %s', lock_key)
304 return get_mutex_lock(self.client, lock_key, self._lock_timeout,
303 return get_mutex_lock(self.client, lock_key, self._lock_timeout,
305 auto_renewal=self._lock_auto_renewal)
304 auto_renewal=self._lock_auto_renewal)
306 else:
305 else:
@@ -333,12 +332,22 b' def get_mutex_lock(client, lock_key, loc'
333 strict=True,
332 strict=True,
334 )
333 )
335
334
335 def __repr__(self):
336 return "{}:{}".format(self.__class__.__name__, lock_key)
337
338 def __str__(self):
339 return "{}:{}".format(self.__class__.__name__, lock_key)
340
336 def __init__(self):
341 def __init__(self):
337 self.lock = self.get_lock()
342 self.lock = self.get_lock()
343 self.lock_key = lock_key
338
344
339 def acquire(self, wait=True):
345 def acquire(self, wait=True):
346 log.debug('Trying to acquire Redis lock for key %s', self.lock_key)
340 try:
347 try:
341 return self.lock.acquire(wait)
348 acquired = self.lock.acquire(wait)
349 log.debug('Got lock for key %s, %s', self.lock_key, acquired)
350 return acquired
342 except redis_lock.AlreadyAcquired:
351 except redis_lock.AlreadyAcquired:
343 return False
352 return False
344 except redis_lock.AlreadyStarted:
353 except redis_lock.AlreadyStarted:
@@ -122,7 +122,11 b' class RhodeCodeCacheRegion(CacheRegion):'
122
122
123 if not condition:
123 if not condition:
124 log.debug('Calling un-cached func:%s', user_func.func_name)
124 log.debug('Calling un-cached func:%s', user_func.func_name)
125 return user_func(*arg, **kw)
125 start = time.time()
126 result = user_func(*arg, **kw)
127 total = time.time() - start
128 log.debug('un-cached func:%s took %.4fs', user_func.func_name, total)
129 return result
126
130
127 key = key_generator(*arg, **kw)
131 key = key_generator(*arg, **kw)
128
132
General Comments 0
You need to be logged in to leave comments. Login now