[HOTFIX] Release Python GIL & reset threat state

This commit is contained in:
Paulchen Panther 2020-11-01 09:38:55 +01:00 committed by GitHub
parent 1d6664d4f0
commit 4928117e8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,7 +19,8 @@ PythonProgram::PythonProgram(const QString & name, Logger * log) :
_tstate = Py_NewInterpreter();
if(_tstate == nullptr)
{
PyEval_ReleaseLock();
PyThreadState_Swap(mainThreadState);
PyEval_SaveThread();
Error(_log, "Failed to get thread state for %s",QSTRING_CSTR(_name));
return;
}
@ -54,7 +55,8 @@ PythonProgram::~PythonProgram()
// Clean up the thread state
Py_EndInterpreter(_tstate);
PyEval_ReleaseLock();
PyThreadState_Swap(mainThreadState);
PyEval_SaveThread();
}
void PythonProgram::execute(const QByteArray & python_code)