[mod_python] Shared Memory

Jorey Bump list at joreybump.com
Thu Apr 14 10:59:04 EDT 2005


Huzaifa Tapal wrote:
> If I have two directories in my cgi-bin such as "mp1" and "mp2" that i 
> have setup in httpd.conf to be process by mod_python in two separate 
> configuration blocks such as:
> 
> <Directory "/home/user/www/cgi-bin/mp1">
>    AddHandler mod_python .py
>    PythonHandler mptest
>    PythonDebug On
>    PythonAutoReload On
> </Directory>
> 
> <Directory "/home/user/www/cgi-bin/mp2">
>    AddHandler mod_python .py
>    PythonHandler mptest
>    PythonDebug On
>    PythonAutoReload On
> </Directory>
> 
> Would modules loaded in the application of mp1 be cached and shared with 
> module being used in mp2 and vice-versa? 

Yes, by default they will share the interpreter. An interpreter is 
created for each virtual host.

> The reason I ask is that I 
> have somewhat of a similar setup where I have a production framework 
> running under mod_python in say "mp1" and then a beta framework running 
> under mod_python in say "mp2" and they both reference a separate 
> production and beta installations of the applications, however, when 
> running the beta application (which gets updated before pushing to 
> production for testing) I get errors from the beta application 
> refrencing a library module in the production which are not updated with 
> new code.
> 
> Any ideas on how I can setup a beta installation and production 
> installation of the mod_python framework on the same server so that both 
> access their own shared memory?

The easiest way is to create separate virtual hosts. This will be the 
safest and most flexible, by far. It is also possible to control the 
creation of interpreters somewhat using special directives:

  http://www.modpython.org/live/current/doc-html/dir-other.html

These work very well, but can add a layer of complexity that you won't 
have to deal with if you use separate virtual hosts.


More information about the Mod_python mailing list