/// Performs the call to Python bool PythonScript::executeString() { emit started(MSG_STARTED); bool success(false); ScopedPythonGIL lock; PyObject *compiledCode = compileToByteCode(false); PyObject *result(nullptr); if (compiledCode) { result = executeCompiledCode(compiledCode); } // If an error has occurred we need to construct the error message // before any other python code is run if (!result) { emit_error(); // If a script was aborted we both raise a KeyboardInterrupt and // call Algorithm::cancel to make sure we capture it. The doubling // can leave an interrupt in the pipeline so we clear it was we've // got the error info out m_interp->raiseAsyncException(m_threadID, nullptr); } else { emit finished(MSG_FINISHED); success = true; if (isInteractive()) { generateAutoCompleteList(); } } Py_XDECREF(compiledCode); Py_XDECREF(result); return success; }
/// Performs the call to Python bool PythonScript::executeString() { emit started(MSG_STARTED); bool success(false); GlobalInterpreterLock gil; PyObject * compiledCode = compileToByteCode(false); PyObject *result(NULL); if(compiledCode) { result = executeCompiledCode(compiledCode); } // If an error has occurred we need to construct the error message // before any other python code is run QString msg; if(!result) { emit_error(); } else { emit finished(MSG_FINISHED); success = true; } if(isInteractive()) { generateAutoCompleteList(); } Py_XDECREF(compiledCode); Py_XDECREF(result); return success; }