Boost logo

Boost Users :

From: Ed Fear (edfear_at_[hidden])
Date: 2004-08-15 13:32:59

Hello there,

I've just started using Boost.Python, and find it absolutely
invaluable. For the moment, my main task is embedding the python
interpreter within an application of mine, and I have successfully
built a small application that can load a module, execute a Python
function and then collect the result.

The next logical step was to extend the Python script somewhat into
objects. I wrote some extra code in the script which I checked with
the command line interpreter and verified to work. Before changing
the C++ code to actually /use/ these new objects, I decided to just
see what would happen if I kept exactly the same C++ code but with the
new Python script (which still contains the function used for the last

It ran fine - producing the correct output - but then exited abruptly
with the following message: "Fatal Python error: PyThreadState_Get: no
current thread". The changes to the original script file were the
addition of two new classes - OptionsGUI and Button - and, oddly,
commenting out Button makes the program work again (I say oddly
because it's simply a class with a constructor, nothing more).

Evidently I'm using the library incorrectly, and have searched through
the documentation for things I might have done wrong but alas, I do
find it rather daunting. I also noticed that my code is quite
different from examples - is this a correct way to be doing things?
And yes, at present, I'm not doing any exception or error handling -
I'm a little unclear on it but I'm sure I will be able to do it given
time :)

For those wishing to look at the source, I have put the two files -
EmbeddedPythonFunc.cpp and - in my webspace to prevent
everyone having to download them as attachments. They are available
at the following addresses:

(incidentally, I didn't include stdafx.h because it simply includes
iostream, tchar.h and boost/python.hpp).

I hope I have sent my help request to the right place! Apologies if I have not.

Thank you in advance,
Ed Fear

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at