From 4928117e8e662fd434fbdd4324099dd029e7482a Mon Sep 17 00:00:00 2001 From: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com> Date: Sun, 1 Nov 2020 09:38:55 +0100 Subject: [PATCH] [HOTFIX] Release Python GIL & reset threat state --- libsrc/python/PythonProgram.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libsrc/python/PythonProgram.cpp b/libsrc/python/PythonProgram.cpp index e2cb925e..6144049f 100644 --- a/libsrc/python/PythonProgram.cpp +++ b/libsrc/python/PythonProgram.cpp @@ -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)