[C++-sig] Duplicate registration of to-Python converters
Pertti Kellomäki
pk at cs.tut.fi
Fri Mar 23 08:12:12 CET 2007
David Abrahams wrote:
> on Thu Mar 22 2007, Pertti Kellomäki <pk-AT-cs.tut.fi> wrote:
>> I am able to run Python code with repeated sequences of
>>
>> Py_Initialize()
>> PyRun_SimpleFile()
>> Py_Finalize()
>>
>> so am I just being lucky that the ill effects have not
>> surfaced? This is on Ubuntu, g++ 4.1.2, Boost 1.33.1
>
> Probably, yes, you've gotten lucky.
Googling for Py_Finalize() suggests that the above may not be
advisable regardless of whether one uses Boost.Python or not.
That's fine, I can easily live with one global interpreter
whose state persists.
So what is the correct way to use Boost.Python in an embedded
setting? Is it safe to call Py_Initialize() once, then run scripts
using PyRun_SimpleFile(), and at the end just let exit() reclaim
the resources held by the Python interpreter?
--
Pertti
More information about the Cplusplus-sig
mailing list