[C++-sig] Re: Reinitialization of interpreter with Boost.Python

David Abrahams dave at boost-consulting.com
Wed Apr 7 16:39:51 CEST 2004


Maciej Sobczak <prog at msobczak.com> writes:

> I have hacked the above function and removed both assertion and if, so
> that the conversion function pointer is always written into the slot.
> The second time my module is imported (after the interpreter is
> finalized and re-initialized), the insert function above will just
> overwrite the slot with the same value as before.
> Interestingly, it started to work as expected, at least with simple
> tests.

I wouldn't expect it to keep working.
>
> What bothers me is the claim I found on Boost site, that
> reinitialization of Python interpreter is *not* supported due to the
> reference-counting problems affecting some global objects.
> I do not experience any problems *at the moment*, but I would like to
> know where the trolls may come from.
>
> What is exactly the problem? What should I be aware of?

I think http://www.boost.org/libs/python/todo.html#pyfinalize-safety
explains pretty well: They'll come when your application exits and
global objects are destroyed, decrementing reference counts to zero
after the interpreter is finalized.  Also, objects may leak every
time the interpreter is finalized.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list