nested embedding of interpreter

Antoine Pitrou solipsis at pitrou.net
Mon Feb 6 14:59:24 EST 2012


Hello,

Eric Frederich <eric.frederich <at> gmail.com> writes:
> 
> 1)Is calling Py_Initialize twice correct, or will I run into other problems
> down the road?

It's fine in practice (spurious calls are ignored).

> I am not sure if there is a mechanism to get something called at the end of
the 
> user's session with the program though, so is it a problem if I don't call
> Py_Finalize at the end?

Yes, it's a problem. If you don't call Py_Finalize, atexit handlers, object
destructors and the like will not be called. These include destructors of file
objects (including stdout): any buffering in a still-open file opened for
writing can be lost.

Regards

Antoine.





More information about the Python-list mailing list