Safe to call Py_Initialize() frequently?

Aahz aahz at pythoncraft.com
Sun Mar 29 13:35:09 EDT 2009


[p&e]

In article <e97efd52-4868-47a5-91ec-657bba5f0f48 at z16g2000prd.googlegroups.com>,
Graham Dumpleton  <Graham.Dumpleton at gmail.com> wrote:
>
>In mod_wsgi however, Apache will completely unload the mod_wsgi module
>on a restart. This would also mean that the Python library is also
>unloaded from memory. When it reloads both, the global static
>variables where information was left behind have been lost and nulled
>out. Thus Python when initialised again, will recreate the data it
>needs.
>
>So, for case where Python library unloaded, looks like may well suffer
>a memory leak regardless.
>
>As to third party C extension modules, they aren't really an issue,
>because all that is done in Apache parent process is Py_Initialize()
>and Py_Finalize() and nothing else really. Just done to get
>interpreter setup before forking child processes.
>
>There is more detail on this analysis in that thread on mod_wsgi list
>at:

Missing reference?
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it."  --Brian W. Kernighan



More information about the Python-list mailing list