Help on ImportError('Error: Reinit is forbidden')
Jason Qian
jqian at tibco.com
Wed May 17 15:32:23 EDT 2023
Hi,
I Need some of your help.
I have the following C code to import *Import python.* It works 99% of
the time, but sometimes receives "*ImportError('Error: Reinit is
forbidden')*". error.
**We run multiple instances of the app parallelly.
*** Python version(3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC
v.1914 64 bit (AMD64)]
PyObject * importPythonModule(const char* pmodName)
{
const char* errors = NULL;
int nlen = strlen(pmodName);
PyObject *pName = PyUnicode_DecodeUTF8(pmodName, nlen, errors);
PyObject *pModule = *PyImport_Import*(pName);
Py_DECREF(pName);
if (pModule == NULL) {
if (*PyErr_Occurred*()) {
handleError("PyImport_Import()");
}
}
}
void handleError(const char* msg)
{
...
"PyImport_Import() - ImportError('Error: Reinit is forbidden')"
}
Thanks
Jason
More information about the Python-list
mailing list