Safe to call Py_Initialize() frequently?

Aahz aahz at
Sun Mar 29 19:35:09 CEST 2009


In article <e97efd52-4868-47a5-91ec-657bba5f0f48 at>,
Graham Dumpleton  <Graham.Dumpleton at> 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
>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

Missing reference?
Aahz (aahz at           <*>

"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