Show More
@@ -300,7 +300,6 b' class BaseRedisBackend(redis_backend.Red' | |||
|
300 | 300 | def get_mutex(self, key): |
|
301 | 301 | if self.distributed_lock: |
|
302 | 302 | lock_key = redis_backend.u('_lock_{0}').format(key) |
|
303 | log.debug('Trying to acquire Redis lock for key %s', lock_key) | |
|
304 | 303 | return get_mutex_lock(self.client, lock_key, self._lock_timeout, |
|
305 | 304 | auto_renewal=self._lock_auto_renewal) |
|
306 | 305 | else: |
@@ -333,12 +332,22 b' def get_mutex_lock(client, lock_key, loc' | |||
|
333 | 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 | 341 | def __init__(self): |
|
337 | 342 | self.lock = self.get_lock() |
|
343 | self.lock_key = lock_key | |
|
338 | 344 | |
|
339 | 345 | def acquire(self, wait=True): |
|
346 | log.debug('Trying to acquire Redis lock for key %s', self.lock_key) | |
|
340 | 347 | try: |
|
341 |
|
|
|
348 | acquired = self.lock.acquire(wait) | |
|
349 | log.debug('Got lock for key %s, %s', self.lock_key, acquired) | |
|
350 | return acquired | |
|
342 | 351 | except redis_lock.AlreadyAcquired: |
|
343 | 352 | return False |
|
344 | 353 | except redis_lock.AlreadyStarted: |
@@ -122,7 +122,11 b' class RhodeCodeCacheRegion(CacheRegion):' | |||
|
122 | 122 | |
|
123 | 123 | if not condition: |
|
124 | 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 | 131 | key = key_generator(*arg, **kw) |
|
128 | 132 |
General Comments 0
You need to be logged in to leave comments.
Login now