[mod_python] Single import at startup

Graham Dumpleton grahamd at dscpl.com.au
Fri Sep 16 06:02:35 EDT 2005


On 15/09/2005, at 4:22 AM, Scott Chapman wrote:

> Lee Brown wrote:
>
>> I agree with you that doing an import once at server startup rather 
>> than at
>> each request seems like a cleaner way to go.  The only drawback is 
>> that if
>> you change the code in the imported module you'll have to re-start the
>> server but this usually isn't a problem for many applications.
>
> It is my understanding that importing once at startup is problematic 
> because the only hook to do it is _before_ the interpreter is 
> established?

Hmmm, what you are saying doesn't make sense. An interpreter has
to exist in order to import a module into it.

If you look at the code what I think you will find is that when
the child process init function is called by Apache, that it will
iterate over the list of modules associated with PythonImport
definitions, creating the named interpreter and then importing
the module into it.

Graham



More information about the Mod_python mailing list