[mod_python] PythonInterpPerDirec* Question

Graham Dumpleton grahamd at dscpl.com.au
Thu Sep 8 22:16:35 EDT 2005

On 09/09/2005, at 7:46 AM, Huzaifa Tapal wrote:

>  Hello all,
>  I have a question about the usage of the PythonInterpPerDirectory and 
> PythonInterpPerDirective directives.  I am trying to setup a 
> development box with mod_python support, and want to set it up in a 
> way so that different users, within their cgi-bin can have multiple 
> mod_python handler installations and each handler having its own set 
> of sub-interpreters.  After doing some research I found that the usage 
> of the above two directives is the solutions (or maybe something else 
> that I am not aware of).
>  I am trying to set the above directive in my httpd.conf file as 
> follows:
>  <Directory /home/*/www/cgi-bin/>
>         PythonInterpPerDirective On       # or 
> PythonInterpPerDirectory On
>  </Directory>

You can check whether this is even coming into play by including:

   deny from all

If the path pattern is right, you should then get Forbidden.

>  now I test this by creating two directories within a user's cgi-bin 
> say /home/user/www/cgi-bin/handler1 and 
> /home/user/www/cgi-bin/handler2 and add a handler module and a 
> .htaccess file with the following contents:
> SetHandler mod_python
>  PythonHandler mptest
>  PythonDebug On
>  Within the handlers, I am creating a cache dictionary at global level 
> and testing the cache for that dictionary by printing its values and 
> also printing the id of the cache dictionary.  When executing both 
> handlers, it appears that both handlers in both directories are 
> sharing the subinterpreters when they should not be.

I wouldn't necessarily rely on using Python id() as basis to determine
if they are same/different interpreter.

For starters, simply display value of "req.interpreter". This will be
the name given to each interpreter. It should equate somehow to the path
to the physical directory.

Note that there are some bugs in the PythonInterpPerDirectory directive.


This is address in mod_python 3.2 beta versions.


More information about the Mod_python mailing list