Embedded/Extended w/C++ - Thread error

Mary Austin mfa at skye.cc.gatech.edu
Fri May 7 02:37:33 EDT 1999


Hi!  I'm attempting to have python call functions in C++ and have methods
in C++ call functions in Python (all from the same C++ dll).  The first
direction, I have working just fine (Python calling C++ functions). 
However, the other direction is not so easy.  Whenever I attempt to call
PyImport_ImportModule("<insert any module here>"), it bombs completely -
abnormal program termination.  Even with PyImport_ImportModule("string")
from the _Programming Python_ book.  The error I get just before
python.exe dies is "Fatal Python error: PyThreadState_Get: no current
thread".  This also happens with PyEval_CallObject(...) and
PyObject_CallFunction(...).  The parameters are correct as best as I can
tell (the args are correct and the object passes callable check) and in
fact, PyObject_GetAttrString(...) returns a non-NULL value (I tried
passing in a pointer to the python function I want to call and the python
module that contains the function I want to call from python). 

I'm creating threads from within C++ (the code creates a thread for a
socket to accept connections as well as a thread for each client that's
connected), but Python shouldn't care about them, as the C++ threads
are created by another class than what's calling all the Python commands.
(At least I don't think python should care about them.)

I've even attempted to try some of the very basic examples in the
_Programming Python_ book, and those bomb at the same places.

Anyone have any idea why PyImport_ImportModule, PyEval_CallObject, and
PyObject_CallFunction would cause a thread error when I'm not using Python
threads (only C++ threads from within classes that don't talk to Python)?


Thanks for any help,

Mary

------------------------------------------------------------------------
Mary Austin
PhD Candidate, Georgia Tech College of Computing
Office: CRB 423, 404.385.6014
Fax: 404.894.9846
URL: http://www.cc.gatech.edu/~mfa
------------------------------------------------------------------------






More information about the Python-list mailing list