|
Daniel Popowich
dpopowich at comcast.net
Tue Jun 21 14:35:47 EDT 2005
Manera, Villiam writes:
> I noted a funny behavior on loading servlet, sometime work sometime :
>
> File "/usr/local/lib/python2.4/site-packages/mod_python/servlet.py",
> line 1345, in get_servlet
> klass, servlets = self.__load_servlet(filename)
>
> File "/usr/local/lib/python2.4/site-packages/mod_python/servlet.py",
> line 1276, in __load_servlet
> raise ValueError, ('%s is not a subclass of Servlet (in %s)'
>
> ValueError: menu is not a subclass of Servlet (in
> /discoe/script/cgi/bulgaria/bulgaria_menu.py/menu.mps)
>
> Obviously menu.mps is subclass od Servlet.
>
>
> This happened sometime, on different servlet ????
>
>
> If I restart apache all work fine for some time...
Have you modified servlet.py? If so and PythonAutoReload is "on"
then servlet.py is being reloaded by the python interpreter which
will create a new Servlet class with different identifier than the
one cached by the servlet manager in servlet.py. That's why
restarting apache fixes your problem: you get fresh copies of
everything in new python interpreters.
To avoid this:
1. You really shouldn't change servlet.py. Put
modifications/extensions in subclasses...the power of OO and
all...
2. In development mode, I configure my prefork apache with:
MaxRequestsPerChild 1
Sure, it's a performance hit, but you NEVER have to deal with
stale python module importing issues and you don't have to
litter your code with special-case importing code, etc.
Cheers,
Daniel Popowich
-----------------------------------------------
http://home.comcast.net/~d.popowich/mpservlets/
|