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,...) { PyEval_AcquireLock() threadState = Py_NewInterpreter(); PyThreadState_Swap(threadState);
/* 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 */ Py_EndInterpreter(threadState); PyEval_ReleaseLock(); }. And my python initialise looks as : pythonInit() { Py_initialise(); 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 <structurename_member>_set. 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. Vishnu -- http://mail.python.org/mailman/listinfo/python-list