mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-04-27 03:00:12 -04:00
cache.py: Add a random delay to memcached retries
This should reduce memcached spam during outages
This commit is contained in:
committed by
Brian Simpson
parent
48eacfb036
commit
8fe75df017
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user