using python interpreters per thread in C++ program

ganesh ganeshborse at
Mon Sep 7 09:28:49 CEST 2009

On Sep 7, 2:04 pm, sturlamolden <sturlamol... at> wrote:
> I just showed you how...

Modified the thread function to use these APIs, but the call to
PyGILState_Ensure() is not returning at all.

void *callPyFunction(void * arg)
   // Method two to get function eval
   long thridx=(long)arg;
   printf("\n---->my num=%d, calling showstr pyfunction\n",thridx);
   char callpyf[] = "showstr(100)\n";
   PyGILState_STATE state = PyGILState_Ensure();
   printf("after PyGILState_Ensure\n");
   PyObject* pycall = PyRun_String(callpyf,Py_file_input,glb, loc);
   if(pycall == NULL || PyErr_Occurred()){
      printf("PyRun_String failed\n");
   } else
      printf("%d thread called showstr pyfunction ok\n",thridx);

More information about the Python-list mailing list