Discussion:
DJANGO and modpy reloading hell...
durumdara
2007-04-13 07:20:29 UTC
Permalink
Hi !

I want to substitute my modpy based website to any framework system,
but I have a question:

The development under modpy sometimes became very hard, because the
python in the normal working mode does not reload the modules are
loaded before.

But in web development when we change something in source, the site
need to reflect these changes.
This is not too easy to solve the problems caused by changes (objects
are changed, some globals are flushed, persistent databases closed,
etc.).

The developer sometimes is see only the he/she is refreshed the page,
but nothing is happened. Reload problem occured.

In php that is no problem, because the source is read and interpreted
again by the interpreter, so the changed are reflected in a moment.

Before of modpy 3.3 I used my own system to load and reinterpret pages
(see exec) without this "reload hell".
I want to ask that how to django avoid these problems when I use
modpython gateway?
Or I need to restart my website after modifications?

Thanks for your help:
dd


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Graham Dumpleton
2007-04-13 09:27:58 UTC
Permalink
Post by durumdara
Hi !
I want to substitute my modpy based website to any framework system,
The development under modpy sometimes became very hard, because the
python in the normal working mode does not reload the modules are
loaded before.
But in web development when we change something in source, the site
need to reflect these changes.
This is not too easy to solve the problems caused by changes (objects
are changed, some globals are flushed, persistent databases closed,
etc.).
The developer sometimes is see only the he/she is refreshed the page,
but nothing is happened. Reload problem occured.
In php that is no problem, because the source is read and interpreted
again by the interpreter, so the changed are reflected in a moment.
Before of modpy 3.3 I used my own system to load and reinterpret pages
(see exec) without this "reload hell".
In mod_python 3.3.1 do you use mod_python's own module importer? The
module importer was completely rewritten for that release and as long
as you are disciplined and use it properly, you can go a long way
without needing to restart Apache.
Post by durumdara
I want to ask that how to django avoid these problems when I use
modpython gateway?
Or I need to restart my website after modifications?
Django doesn't avoid these problems. You have no choice when using
Django on top of mod_python but to restart Apache to have it properly
pick up changes as it uses the standard Python module importer.

Graham


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Luciano Adamiak
2007-04-13 12:00:44 UTC
Permalink
Just set "MaxRequestsPerChild 1" in your httpd.conf
Post by Graham Dumpleton
Post by durumdara
Hi !
I want to substitute my modpy based website to any framework system,
The development under modpy sometimes became very hard, because the
python in the normal working mode does not reload the modules are
loaded before.
But in web development when we change something in source, the site
need to reflect these changes.
This is not too easy to solve the problems caused by changes (objects
are changed, some globals are flushed, persistent databases closed,
etc.).
The developer sometimes is see only the he/she is refreshed the page,
but nothing is happened. Reload problem occured.
In php that is no problem, because the source is read and interpreted
again by the interpreter, so the changed are reflected in a moment.
Before of modpy 3.3 I used my own system to load and reinterpret pages
(see exec) without this "reload hell".
In mod_python 3.3.1 do you use mod_python's own module importer? The
module importer was completely rewritten for that release and as long
as you are disciplined and use it properly, you can go a long way
without needing to restart Apache.
Post by durumdara
I want to ask that how to django avoid these problems when I use
modpython gateway?
Or I need to restart my website after modifications?
Django doesn't avoid these problems. You have no choice when using
Django on top of mod_python but to restart Apache to have it properly
pick up changes as it uses the standard Python module importer.
Graham
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
durumdara
2007-04-13 12:54:16 UTC
Permalink
Hi!
Post by Luciano Adamiak
Just set "MaxRequestsPerChild 1" in your httpd.conf
And this parameter is used for whole webserver, or I can set it by
virtualhosts?
(The last solution is better, because the server is handle 15 site...
(python and php)).

dd




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Luciano Adamiak
2007-04-13 12:59:13 UTC
Permalink
It's for the whole thing... I guess

But it will prevent your restarting every change..
Post by durumdara
Hi!
Post by Luciano Adamiak
Just set "MaxRequestsPerChild 1" in your httpd.conf
And this parameter is used for whole webserver, or I can set it by
virtualhosts?
(The last solution is better, because the server is handle 15 site...
(python and php)).
dd
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Graham Dumpleton
2007-04-14 07:53:58 UTC
Permalink
Post by Luciano Adamiak
It's for the whole thing... I guess
But it will prevent your restarting every change..
But it still happens automatically and as a result everything runs
very slowly. At that point you may as well use CGI which may even be a
bit quicker as you aren't restarting all Apache processes, you instead
are only incurring the cost of fork/execing one new process instead.

FWIW, in mod_wsgi you can optionally enable a mode whereby when the
main WSGI application scripts modification time changes, it will
destroy and then recreate the actual sub interpreter within the
existing running process leaving alone any other sub interpreters and
any other Apache modules. The idea is you make the changes you need,
touch the main script file and the reload of the whole Django
application and all modules it uses will happen automatically on the
next request, all without having to restart Apache.

Whether this mechanism in mod_wsgi will work for you with Django
depends a bit on what additional third party Python C extension
modules you use, especially database modules. A basic Django
application with sqlite seems to handle interpreter reloading okay but
more complex database modules may have issues. As an example, neither
Pylons or TurboGears can handle interpreter reloading because they
both rely on PyProtocols which uses some pyrex generated modules.
These pyrex generated modules will cause Apache to crash if a sub
interpreter is destroyed and a new one created and the pyrex generate
module reused. It isn't known yet whether the problem in this case is
with how pyrex generates code or how PyProtocols uses it. Either way,
the basic problem is the C extension module code isn't correct for
working with multiple sub interpreters and doesn't handle destruction
of sub interpreters.

If reloading interpreters doesn't work for your specific application,
the only other choice at this point is to use something like
mod_fastcgi. At least that way when you restart the process, you are
only restarting the process the Python code is running in and you will
not affect other stuff running in Apache. The use of separate daemon
processes for handling just Python requests is being add to mod_wsgi,
but still a bit more work to complete it.

Graham
Post by Luciano Adamiak
Post by durumdara
Hi!
Post by Luciano Adamiak
Just set "MaxRequestsPerChild 1" in your httpd.conf
And this parameter is used for whole webserver, or I can set it by
virtualhosts?
(The last solution is better, because the server is handle 15 site...
(python and php)).
dd
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-***@googlegroups.com
To unsubscribe from this group, send email to django-users-***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Loading...