I am trying to use Jedi https://github.com/davidhalter/jedi to create a custom python editor and I am using c++, it works perfectly, but it is a bit slow and stalls for a small while, so I am calling those functions from inside a thread in c++, but doing so I am having a stack overflow error sometimes.
Here is my code:
//~ Create Script Instance class
PyObject* pScript = PyObject_Call(
PyObject_GetAttrString(GetJediModule(), "Script"),
PyTuple_Pack(1, PyString_FromString(TCHAR_TO_UTF8(*Source))),
NULL);
if (pScript == NULL)
{
UE_LOG(LogTemp, Verbose, TEXT("unable to get Script Class from Jedi Module"));
Py_DECREF(pScript);
ClearPython();
return;
}
//~ Call complete method from Script Class
PyObject* Result = PyObject_Call(
PyObject_GetAttrString(pScript, "complete"),
PyTuple_Pack(2, Py_BuildValue("i", Line), Py_BuildValue("i", Offset)),
NULL);
if (Result == NULL)
{
UE_LOG(LogTemp, Verbose, TEXT("unable to call complete method from Script class"));
Py_DECREF(Result);
ClearPython();
return;
}
The error happens when call PyObject_Call, I assume is because the thread, since it works perfectly when I call the function from the main thread, but the stack is not telling me anything useful, just an error inside the python.dll