Problems embedding python 2.6 in C++
gagsl-py2 at yahoo.com.ar
Wed Feb 3 00:30:17 CET 2010
En Tue, 02 Feb 2010 02:26:57 -0300, Paul <gobladoome at gmail.com> escribió:
> I've managed to get it working and so far stable...
Glad to see you finally made it work!
> Current working version:
> mycppclass::callpy(funcname, args...)
> m_mypymodule = PyImport_Import(pModuleName)
> pyargs = PyTuple_SetItem * args
> So now the module is being imported each function call (luckily I don't
> to worry about performance)
Remember that after the module is successfully imported by the first time,
a subsequent import returns early, as soon as it finds the module in
sys.modules -- the performance penalty shouldn't be so big.
> I assume this means that the internal representation of the imported
> is being corrupted by something. I found another person with a similar
> http://mail.python.org/pipermail/python-dev/2004-March/043306.html -
> that is
> a long time ago but another multi-threaded app.
> I'm happy to use the working method but I'd like to understand what is
> on a bit more. Can anyone shed any further light?
Sorry, I cannot help on this. Seems to happen only with an embedded
interpreter and a multithreaded application, and I've never used Python in
If you could trim your code to a minimal example that shows the faulty
behavior, that would be great, so others can test it too and eventually
determine what's going on.
More information about the Python-list