[mod_python] avoiding apache restarts to reimport modules and refresh global cache

Steve Bergman steve at rueb.com
Thu Sep 15 12:09:33 EDT 2005


Huzaifa Tapal wrote:

> I have been using my python based web application framework, slither, 
> which was recently upgraded to be a mod_python handler for more than 6 
> months now for various applications at my company.  One dillema I see 
> with the persistent environment with mod_python is that everytime I 
> update code in production, i have to restart apache so that my library 
> modules can be reloaded as well as any caching I am using.
>
> I am using apache.import_module() to import any page modules in my 
> applications and those get reimported at every change since they have 
> the autoreload turned on.  I also know that Vampire has a pretty good 
> module importing system then that provided by apache.import_module().  
> I was wondering if it would be a good idea overwrite the 
> __builtin__.import() method with that of Vampire's import_module or 
> apache.import_module() so that the checks of "mtime" are done and the 
> reloads happen automatically.
>
> Is there another better way of reloading all my library modules and 
> refreshing the cache?

I have a possibly related question.  I'm new to mod_python, but I have 
already noticed that if I have a module with a class that has a method 
that returns, say, a list to a calling function in main, and then change 
it to pass back, say, a dictionary, the interpretter sometimes wants to 
continue to act like a list was passed, when the main program is 
expecting a dictionary.  The behavior is inconsistent in that sometimes 
it works right and sometimes not.  I think this might be covered in 
question 3.1 of the FAQ, but I'm not sure I quite understand what it is 
saying.

Could someone enlighten me?

Thanks,

-Steve Bergman


More information about the Mod_python mailing list