Skip to content

Commit 5d0f971

Browse files
murhum1ihalaij1
authored andcommitted
Add RetryingMemcacheClient class
Add a RetryingMemcacheClient class. Using this will allow momentary network errors while fetching course configurations to not stop and fail the whole course build process.
1 parent 088d81b commit 5d0f971

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

gitmanager/settings.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,13 @@
169169
#SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'
170170
##########################################################################
171171

172+
# pymemcache's RetryingClient configuration options
173+
# https://pymemcache.readthedocs.io/en/latest/apidoc/pymemcache.client.retrying.html
174+
RETRYING_MEMCACHE_CLIENT_OPTIONS = {
175+
'attempts': 10,
176+
'retry_delay': 3,
177+
}
178+
172179
# Internationalization
173180
# https://docs.djangoproject.com/en/1.6/topics/i18n/
174181
LANGUAGE_CODE = 'en-us'

util/retrying_memcache_client.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from pymemcache.client import retrying, hash
2+
from django.core.cache.backends.memcached import PyMemcacheCache
3+
from django.conf import settings
4+
5+
class RetryingMemcacheClient(PyMemcacheCache):
6+
def __init__(self, server, params):
7+
super().__init__(server, params)
8+
self._cache = retrying.RetryingClient(
9+
hash.HashClient(self.client_servers, **self._options),
10+
**settings.RETRYING_MEMCACHE_CLIENT_OPTIONS
11+
)

0 commit comments

Comments
 (0)