hi.

i have weird caching problems with the 1.3 version of django. I
probably have something configured wrong, but am not sure what.

A good example is django-avatar, which uses caching and many people
use it. Even if I dont have a cache backend defined the avatar seems
to be cached, which by itself would be ok, but it keeps switching back
and forth between the last values cached. Example: I upload a new
avatar, now on approximately 50% of the requests it will show me the
new one, 50% the old one. If I delete the old one I still get it on
the site 50% of the time. The only way to fix it is to disable the
caching of the avatar by setting it to one second.

First I thought it was because i used
django.core.cache.backends.locmem.LocMemCache, which I never used
before, but it even happens when I dont configure a cache backend at
all.

I found one similar bug:
http://stackoverflow.com/questions/4888470/django-caching-bug-even-if-caching-is-disabled

but my pages render just fine, its the templatetags (for now) that
cause the problems in my setup.

I use django 1.3, postgres, nginx, gunicorn 0.12.0, greenlet==0.3.1,
eventlet==0.9.16

I just did some more testing and realized that it only happens when I
start gunicorn using the config file. If I start it with ./manage.py
run_gunicorn everything is fine. Running "gunicorn_django -c deploy/
gunicorn.conf.py" causes the problems.

The only explanation I can think of is that each worker gets his own
cache (I wonder why, since I did not define a cache).

Update: running ./manage.py run_gunicorn -w 4 also causes the same
problems. Therefore I am almost certain that the multiple workers are
causing the problems and each worker caches the values seperately.

My configuration:

import os
import socket
import sys

PORT = 8000
PROC_NAME = 'myapp_gunicorn'
LOGFILE_NAME = 'gunicorn.log'
TIMEOUT = 3600
IP = '127.0.0.1'
DEPLOYMENT_ROOT = os.path.dirname(os.path.abspath(__file__))
SITE_ROOT = os.path.abspath(os.path.sep.join([DEPLOYMENT_ROOT, '..']))
CPU_CORES = os.sysconf("SC_NPROCESSORS_ONLN")
sys.path.insert(0, os.path.join(SITE_ROOT, "apps"))
bind = '%s:%s' % (IP, PORT)
logfile = os.path.sep.join([DEPLOYMENT_ROOT, 'logs', LOGFILE_NAME])
proc_name = PROC_NAME
timeout = TIMEOUT
worker_class = 'eventlet'
workers = 2 * CPU_CORES + 1

-----------------------------------
I also tried it without using 'eventlet', but got the same errors.


Thanks for any help.
Philipp

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to