Hi :)
I want to run Python in my app. That works still fine. But my app
supports now Threads and I would like to know what to do, that it runs
without problems.
PyGILState_Rele ase and PyGILState_Ensu re should solve the problem
right? Where do I have to put this two commands around? between each
Command that increase, decrease a reference?
Currently, this is a small code-snippet that represents the part of
the code-execution:
PyObject *f_globals=NULL , *f_locals=NULL, *mod=NULL, *rv=NULL;
mod = PyImport_Import Module("__main_ _");
if (!mod)
return;
f_globals = PyModule_GetDic t(mod);
f_locals = PyDict_New();
PyDict_Update(f _locals, f_globals);
if (!f_locals) {
Py_DECREF(mod);
PyErr_Print();
return;
}
rv = PyRun_String( <my code , Py_file_input, f_locals,
f_locals);
if (!rv)
PyErr_Print();
Py_XDECREF(rv);
Py_DECREF(mod);
Py_DECREF(f_loc als);
Py_DECREF(f_loc als);
Thanks a lot for your help :)
I want to run Python in my app. That works still fine. But my app
supports now Threads and I would like to know what to do, that it runs
without problems.
PyGILState_Rele ase and PyGILState_Ensu re should solve the problem
right? Where do I have to put this two commands around? between each
Command that increase, decrease a reference?
Currently, this is a small code-snippet that represents the part of
the code-execution:
PyObject *f_globals=NULL , *f_locals=NULL, *mod=NULL, *rv=NULL;
mod = PyImport_Import Module("__main_ _");
if (!mod)
return;
f_globals = PyModule_GetDic t(mod);
f_locals = PyDict_New();
PyDict_Update(f _locals, f_globals);
if (!f_locals) {
Py_DECREF(mod);
PyErr_Print();
return;
}
rv = PyRun_String( <my code , Py_file_input, f_locals,
f_locals);
if (!rv)
PyErr_Print();
Py_XDECREF(rv);
Py_DECREF(mod);
Py_DECREF(f_loc als);
Py_DECREF(f_loc als);
Thanks a lot for your help :)
Comment