Graham Dumpleton <graham.dumple...@gmail.com> added the comment:

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

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11803>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to