cache.py: Add a random delay to memcached retries

This should reduce memcached spam during outages
This commit is contained in:
Robert Ditthardt
2014-12-08 11:27:59 -08:00
committed by Brian Simpson
parent 48eacfb036
commit 8fe75df017

View File

@@ -27,12 +27,15 @@ import cPickle as pickle
from copy import copy
from curses.ascii import isgraph
import logging
from time import sleep
from pylons import g
import pylibmc
from _pylibmc import MemcachedError
import random
from pycassa import ColumnFamily
from pycassa.cassandra.ttypes import ConsistencyLevel
@@ -176,6 +179,7 @@ class CMemcache(CacheUtils):
raise
except MemcachedError as e:
ex = e
sleep(random.uniform(0, 0.1))
event_name = "cache.retry.%s" % fn.__name__
g.stats.event_count(event_name, "fail")