On Oct 23, 3:01 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, Oct 22, 2008 at 11:31 AM, GPSGuy <[EMAIL PROTECTED]> wrote:
>
> > Option One: Reloading Wrapper
> > I now that there is caching going on, but I am still not sure why. I
> > did find a work around, though I would still like for someone to
> > explain what is going on underneath.
>
> Apache does not automatically re-load all of your Python code into memory
> for each request. Doing so would be an incredible performance hit for a
> production environment where the code generally does not change very often.
> So, once the code is loaded into a process it is re-used for as long as that
> process is used to service requests (dependent on Apache configuration
> parameters). I am not sure why you are seeing a 15 seconds, exactly, since
> generally it's a number of requests per child process that controls this,
> but I am not an Apache configuration expert so there may be some other
> config option that your server is using to control this.
>
> The reason that you see the date/time change for each request but not a
> variable you have changed in the view is that the code for generating the
> date/time does not change, and it runs for each request, producing the
> current date/time. Your code runs for each request, but not necessarily the
> most recent code on the disk. Thus you have to wait for your code to be
> re-loaded in order to see the variable value change reflected in the
> generated response.
>
> There are ways to configure Apache so that you can trigger it to reload your
> code without a restart. For example, if you use mod_wsgi you can configure
> things so that all you need to do is touch your script file to cause all
> your code to be reloaded, see "Reloading Source Code" on this page:
>
> http://code.google.com/p/modwsgi/wiki/FrequentlyAskedQuestions
>
> Or, you can force the reload yourself by doing the view wrapping with
> explicit reload as you have shown. But really, it's much easier to just use
> the development server. I don't really understand why you'd rather use this
> dedicated Apache that isn't really dedicated to you since restarting it
> affects others.
Also see:
http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode#Restarting_Daemon_Processes
The monitoring code in that section can quite happily be used to give
you a measure of automatic process reloading without the need for
touching the WSGI script file. It does this by monitoring changes to
Python code files associated with loaded Python modules. It can also
be told to monitor non Python code files as well if necessary.
The code there should only be used with mod_wsgi daemon mode and for
development, would recommend a single daemon mode process. If that
daemon mode uses a single thread, it wouldn't then be too much
different to using Django development server.
Graham
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---