3👍
Looking at the python-memcached code on launchpad, you should be able to tweak dead_retry
and retry_timeout
. Another option may be to run a low memory, low connections instance of memcached on one or both of the app servers as a fallback when the primary memcached server is unreachable.
6👍
Just solved same problem with apt-get install memcached
. May be it’s your case too.
Ou, sorry, this is not your case. I’vr just read question with more attention. But I will left my answer – cause it’s about this runtime error.
- Django 1.6: How to access static files in view
- Sphinx and re-usable Django apps
- Django Models Number Field
3👍
https://github.com/django/django/blob/master/django/contrib/sessions/backends/cache.py
def create(self):
# Because a cache can fail silently (e.g. memcache), we don't know if
# we are failing to create a new session because of a key collision or
# because the cache is missing. So we try for a (large) number of times
# and then raise an exception. That's the risk you shoulder if using
# cache backing.
for i in xrange(10000):
self._session_key = self._get_new_session_key()
try:
self.save(must_create=True)
except CreateError:
continue
self.modified = True
return
raise RuntimeError("Unable to create a new session key.")
- you can monkey-patch
django.contrib.sessions.backends.base.SessionBase._get_new_session_key
to do atime.sleep(0.001)
. - you could also check your entropy:
here’s the command:
cat /proc/sys/kernel/random/entropy_avail
2👍
I was getting this error running a local, development version of a Django project, because it was periodically having trouble connecting to a non-local cache. I realized that I could change my session backend to a file-based session to address the issue .
In the settings file for this local, development version of Django, I simply set the following value:
SESSION_ENGINE = 'django.contrib.sessions.backends.file'
This is not the solution I would use in a production environment, and not the solution I would suggest to the original poster, but it took me a few minutes to figure out what the issue was and this is one of the only results that appeared when I Googled, so I figured I’d post here possibly to help out others with a similar issue.
2👍
In the memcache config file (e.g., /etc/sysconfig/memcached
or /etc/memcached.conf
), you may need to change:
-l 127.0.0.1
to
-l 0.0.0.0
to allow the web server to connect to the memcache server (if they are on different hosts).
- Django-Pinax : How do you use a pinax app apart from what you get with a pinax base project?
- Passing an object created with SubFactory and LazyAttribute to a RelatedFactory in factory_boy
- Sphinx-apidoc on django build html failure on `django.core.exceptions.AppRegistryNotReady`
-1👍
Same issue I faced, Check ports configured in django and memcached.May be both are different.
you can change memcached port vim /etc/memcached.conf find ‘Default connection port is’ changed according to your need restart memcached services
- Django + Pydev/Eclipse + Google App Engine – possible?
- Django. ''The `actions` argument must be provided when calling `.as_view()` '' when I try to allow DELETE, PUT, ETC
- Django queryset return single value
- Why isn't psycopg2 executing any of my SQL functions? (IndexError: tuple index out of range)
- What's the purpose of Django "deconstruct" model field function?
-1👍
This is exactly CPU shortage. when the request goes to be completed watching /var/log/apache/error.log could be the best place for monitoring. also take htop tp monitor your cpu while you are working with web console.
you should increase CPU cores
- Generating single access token with Django OAuth2 Toolkit
- Why is Django's Meta an old-style class?
- How do I serve media files in a local Django environment?
- Accessing Django OneToOneField in templates?
- 'TemplateDoesNotExist' error with creating Sitemap for Django app