This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author grahamd
Recipients amaury.forgeotdarc, christian.heimes, ezio.melotti, grahamd, jcea, loewis, ncoghlan, pitrou, python-dev, swapnil, vstinner
Date 2011-04-11.22:41:56
SpamBayes Score 6.1568613e-07
Marked as misclassified No
Message-id <1302561720.56.0.420081853325.issue11803@psf.upfronthosting.co.za>
In-reply-to
Content
I wouldn't use mod_python as any guide for how to use sub interpreters as its usage of sub interpreters and threading in conjunction with them is technically broken, not following properly the Python C API requirements. It doesn't even shutdown the Python interpreters properly resulting in memory leaks on Apache restarts into the Apache parent process which is then inherited by all forked Apache child processes.

Also, mod_python does not destroy sub interpreters within the life of the process and then create replacements. It is a bit of a misconception that some have that mod_python creates a new sub interpreter for each request, it doesn't. Instead once a sub interpreter is created it persists for the life of the process. Thus it doesn't even trigger the scenario you talk about.

In early versions of mod_wsgi the recycling of sub interpreters within the lifetime of the process was tried but was found not to be practical and feature was removed. The big stumbling block was third party C extensions. Various C extensions do not cope well with being initialised within context of one sub interpreter, with the sub interpreter being destroyed, and the C extension then being used in context of another sub interpreter. This usage pattern caused memory leaks in some cases and in worst case the process would crash.

In short, use of sub interpreters for short periods of time and then destroying them is all but unusable except within very constrained situations where no use is made of complex C extensions.

For related information see:

http://blog.dscpl.com.au/2009/03/python-interpreter-is-not-created-for.html
http://blog.dscpl.com.au/2009/11/save-on-memory-with-modwsgi-30.html
History
Date User Action Args
2011-04-11 22:42:00grahamdsetrecipients: + grahamd, loewis, jcea, amaury.forgeotdarc, ncoghlan, pitrou, vstinner, christian.heimes, ezio.melotti, swapnil, python-dev
2011-04-11 22:42:00grahamdsetmessageid: <1302561720.56.0.420081853325.issue11803@psf.upfronthosting.co.za>
2011-04-11 22:41:57grahamdlinkissue11803 messages
2011-04-11 22:41:56grahamdcreate