On Mon, Apr 19, 2010 at 1:10 PM, reindyr <rein...@gmail.com> wrote:
> Hi,
>
> I am using django with Apache and mod_python. I have implemented a
> site navigation using the django-nav module. Internally the module
> maintains a dictionary and uses templatetags to generate the desired
> code for the navigation.
>
> Now, if I create new model instances in the django admin, I want this
> changes to be reflected in the navigation. Therefore I have connected
> a signal:
>
> signals.post_save.connect(post_save, sender=Track)
>
> and the post_save method modifies the dictionary for the navigation.
>
> All works well as long as I use the development server. If I switch to
> Apache I have the problem, that my view is not always updated. That
> means, If I keep hitting F5 in the browser, sometimes I get the old
> view, and sometimes I see the new updated view.
>
> I suspect, it could be a problem that apache starts multiple kernel
> threads. I would except, that the database trigger is executed in all
> instances, but I am not sure. For testing, I have created debug output
> using pythons logging facility and the post_save method is indeed only
> executed once.
>
> I have absolutely no idea where I should look now and would greatly
> appreciate any hints that point me in the right direction.
>
> Cheers,
>
> Thorsten
>

Your conclusions are spot on, which leads to the actual issue -
caching in the wrong place. By storing the navigation data in a
per-process dictionary, it works perfectly when running as a single
process, and less than good in a multi process environment. You need
to pull it out of the process, and store it somewhere accessible to
all processes, eg in a memcached instance, for example, or not bother
caching it at all, and re-calculate on each request (less nice!).

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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