Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Extending embedded python of multiple interpreters

Thread Tools

Extending embedded python of multiple interpreters

Posts: n/a
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.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple independent Python interpreters in a C/C++ program? Python 9 04-13-2008 04:16 PM
Multiple python interpreters within the same process Marcin Kalicinski Python 3 06-09-2007 11:52 PM
embedded: multiple interpreters Shea Martin Ruby 0 01-24-2007 09:45 PM
Looking for advice: supporting multiple embedded interpreters Paul Miller Python 4 01-23-2004 03:20 PM
Multiple interpreters in a single process Maciej Sobczak Python 1 01-14-2004 04:38 PM