469,944 Members | 2,314 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,944 developers. It's quick & easy.

Extending embedded python of multiple interpreters

Hello All,

I have embedded python 2.5 in to my C application. As we need the
python scripts to run in multi threaded environment I have used
Py_NewInterpreter() and Py_EndInterpreter each time I execute a run
script function.
The code is as follows:
RunScript(char *pScriptName,char *pFuncName,...)
threadState = Py_NewInterpreter();

/* Import the script module and run the fnc in that script module */
Pyobject *pModule = PyImport_Import(pScriptName);
PyObject *pFunc = PyObject_GetAttrString(pModule, pFuncName);
/* End running the script and calling the script fnc */

And my python initialise looks as :
pythonInit() {
PyEval_initThreads();//which enables multi thread support

Now I am extending the embedded python to expose my application
library API's to python using SWIG. I written one extension module and
from python i am setting the C structure member values which i
wrapped. I execute this python code using call to RunScript (above
function), it works fine for the first time, but from second time
onwards I get an error - Type Error : in method
Hence my question is the same python code worked for first call, but
from 2nd call it is not working. Could any body help me where I am
making mistake.

Is extension modules does not work properly with multiple
interpreters? Does any body had this behaviour when worked with
extension modules and multiple interpreters creation for each thread.

Thanks in Advance for the help.

Mar 31 '07 #1
0 1348

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Tommy Nordgren | last post: by
852 posts views Thread by Mark Tarver | last post: by
113 posts views Thread by John Nagle | last post: by
3 posts views Thread by Marcin Kalicinski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.