سؤال

I am trying to configure MemCached using heroku add-on 'MemCacheCloud' for my Django website. When I run the code which is trying to get/set the cache then I am getting below error

Mar 31 19:36:17 mycloudapp app/web.1:    File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 115, in get_response 
Mar 31 19:36:17 mycloudapp app/web.1:      response = callback(request, *callback_args, **callback_kwargs) 
Mar 31 19:36:17 mycloudapp app/web.1:    File "/app/.heroku/python/lib/python2.7/site-packages/newrelic-2.12.0.10/newrelic/hooks/framework_django.py", line 492, in wrapper 
Mar 31 19:36:17 mycloudapp app/web.1:      return wrapped(*args, **kwargs) 
Mar 31 19:36:17 mycloudapp app/web.1:    File "/app/jobs/views.py", line 53, in job_view 
Mar 31 19:36:17 mycloudapp app/web.1:      skill_list = get_all_skills() 
Mar 31 19:36:17 mycloudapp app/web.1:    File "/app/common/dataaccess.py", line 13, in get_all_skills 
Mar 31 19:36:17 mycloudapp app/web.1:      cache.set(ALL_SKILLS, skill_list) 
Mar 31 19:36:17 mycloudapp app/web.1:    File "/app/.heroku/python/lib/python2.7/site-packages/django/core/cache/backends/memcached.py", line 71, in set 
Mar 31 19:36:17 mycloudapp app/web.1:      self._cache.set(key, value, self._get_memcache_timeout(timeout)) 
Mar 31 19:36:17 mycloudapp app/web.1:    File "/app/.heroku/python/lib/python2.7/site-packages/newrelic-2.12.0.10/newrelic/api/memcache_trace.py", line 70, in __call__ 
Mar 31 19:36:17 mycloudapp app/web.1:      return self._nr_next_object(*args, **kwargs) 
Mar 31 19:36:17 mycloudapp app/web.1:    File "/app/.heroku/python/lib/python2.7/site-packages/bmemcached/client.py", line 126, in set 
Mar 31 19:36:17 mycloudapp app/web.1:      returns.append(server.set(key, value, time)) 
Mar 31 19:36:17 mycloudapp app/web.1:    File "/app/.heroku/python/lib/python2.7/site-packages/bmemcached/protocol.py", line 372, in set 
Mar 31 19:36:17 mycloudapp app/web.1:      return self._set_add_replace('set', key, value, time) 
Mar 31 19:36:17 mycloudapp app/web.1:    File "/app/.heroku/python/lib/python2.7/site-packages/bmemcached/protocol.py", line 345, in _set_add_replace 
Mar 31 19:36:17 mycloudapp app/web.1:      time, key, value)) 
Mar 31 19:36:17 mycloudapp app/web.1:    File "/app/.heroku/python/lib/python2.7/socket.py", line 224, in meth 
Mar 31 19:36:17 mycloudapp app/web.1:      return getattr(self._sock,name)(*args) 
Mar 31 19:36:17 mycloudapp app/web.1:    File "/app/.heroku/python/lib/python2.7/socket.py", line 170, in _dummy 
Mar 31 19:36:17 mycloudapp app/web.1:      raise error(EBADF, 'Bad file descriptor') 
Mar 31 19:36:17 mycloudapp app/web.1:  error: [Errno 9] Bad file descriptor 

My code to access the cache in dataaccess.py -

from django.core.cache import cache

ALL_SKILLS = "allskills"
def get_all_skills():
    skill_list = cache.get(ALL_SKILLS)
    if not skill_list:
        skill_list = MySkillTable.objects.all()
        cache.set(ALL_SKILLS, skill_list)
    return skill_list

My settings.py has an entry

CACHES = {
      'default': {
        'BACKEND': 'django_bmemcached.memcached.BMemcached',
        'LOCATION': get_env_setting('MEMCACHEDCLOUD_SERVERS').split(','),
        'OPTIONS': {
                    'username': get_env_setting('MEMCACHEDCLOUD_USERNAME'),
                    'password': get_env_setting('MEMCACHEDCLOUD_PASSWORD')
            }
      }
}

When I comment cache.set & cache.get lines in dataaccess.py, code works perfectly.

هل كانت مفيدة؟

المحلول

Thanks @ChrisWesseling for the suggestion.

As per the communication from support the issue#25 was opened against the said problem. Now it has been fixed and as per them pip repository is also updated with the fix.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top