When working with mod_python, it is important to be aware of a feature of Python that is normally not used when using the language for writing scripts to be run from command line. This feature is not available from within Python itself and can only be accessed through the C language API.
Python C API provides the ability to create subinterpreters. A more detailed description of a subinterpreter is given in the documentation for the Py_NewInterpreter()" >Py_NewInterpreter() function. For this discussion, it will suffice to say that each subinterpreter has its own separate namespace, not accessible from other subinterpreters. Subinterpreters are very useful to make sure that separate programs running under the same Apache server do not interfere with one another.
At server start-up or mod_python initialization time, mod_python
initializes an interpreter called main interpreter. The main
interpreter contains a dictionary of subinterpreters. Initially, this
dictionary is empty. With every request, as needed, subinterpreters
are created, and references to them are stored in this dictionary. The
dictionary is keyed on a string, also known as interpreter
name. This name can be any string. The main interpreter is named
"main_interpreter". The way all other interpreters are named can
be controlled by
Once created, a subinterpreter will be reused for subsequent requests. It is never destroyed and exists until the Apache process dies.
You can find out the name of the interpreter under which you're running by peeking at req.interpreter.
What is this????|