[mod_python] Single import at startup

Nicolas Lehuen nicolas.lehuen at gmail.com
Wed Sep 14 14:49:36 EDT 2005


Why not use import in the handler code or the published module ? AFAIK this 
should import the module only once per interpreter. I don't understand the 
advantage of importing a module as soon as the interpreter is created vs 
importing the module when it is needed (i.e. in the handler module or 
published page). Performance-wise, to me, both ways are similar, and the 
second has the benefit of actually working :).

Regards,
Nicolas

2005/9/14, Scott Chapman <scott_list at mischko.com>:
> 
> 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
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20050914/531ffa3f/attachment.html


More information about the Mod_python mailing list