[mod_python] Single import at startup

Scott Chapman scott_list at mischko.com
Wed Sep 14 14:22:32 EDT 2005


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?

I'd like to suggest that mod_python be modified in the next(?) version to enable 
  a hook for importing after the interpreter is established.  This would become 
the default place to connect to the database with persistent connection, etc. as 
well.  I think mod_perl supports this more "intuitively".

If anyone has found a clean way to do this stuff in the existing environment, 
please educate! :)

Scott


More information about the Mod_python mailing list