[mod_python] VirtualDocumentRoot, PythonPath and Subinterpreters

Graham Dumpleton grahamd at dscpl.com.au
Tue Jan 31 05:11:48 EST 2006


On 31/01/2006, at 6:36 PM, Troy Kruthoff wrote:

> How does one go about getting mod_python to know the DocumentRoot when
> using the apache VirtualDocumentRoot directive?  Below is a my vhost
> conf showing what I am trying to accomplish (I'm trying to get the
> PythonPath to match the VirtualDocumentRoot:
>
> <VirtualHost *:80>
>     ServerAdmin webmas... at dummy-host.example.com
>     UseCanonicalName Off
>     VirtualDocumentRoot /www/vhosts/%0
>
>     DirectoryIndex index.py
>     PythonPath "sys.path+['/www/vhosts/%0']"
>     AddHandler mod_python .py
>     PythonHandler index
>     PythonDebug On
>     ServerName *.example.com
>     ErrorLog logs/dummy-host.example.com-error_log
>     CustomLog logs/dummy-host.example.com-access_log common
> </VirtualHost>

I'll have to read properly what you are writing about and think about  
it,
but not sure there is a real clean way in current mod_python versions
of handling this. There has been requests for something that would
allow wildcarding on PythonPath previously, see:

   https://issues.apache.org/jira/browse/MODPYTHON-63

but I don't believe the suggested changes were practical given current
issues with the module importing system.

It is possible that with changes I will be proposing to the module  
importing
system and how updates to PythonPath are managed and/or avoided,
that this may be more practical to do.

> This type of setup makes it viable to run thousands of vhosts from a
> single httpd.conf file, and allows the addition and deletion of vhosts
> without restarting apache.  This brings me to another point.  If we
> are planning to use the worker MPM, a sub-interpreter will be created
> for each vhost.  I'm assuming if we can get VirtualDocumentRoot to
> work, that the same will apply.  Does anyone know:
>
> 1)  How many sub-interpreters is too much?

Good question. Anyone got an answer to this based on actual usage?
I would image that more than a small number may blow out process
sizes too much.

> 2)  Is there a way to monitor sub-interpreters and kill stale ones?

No. Only way is to do an "apachectl graceful" restart to kill off child
processes and start new ones to replace them.

Graham



More information about the Mod_python mailing list