From 189a99d1f90e9ebec103b33e2ccbb3d7b2677eda Mon Sep 17 00:00:00 2001 From: Matthew Andrew <matthew.andrew@stfc.ac.uk> Date: Wed, 15 Aug 2018 09:56:48 +0100 Subject: [PATCH] Changed class name Re #23266 --- .../Environment/ReleaseGlobalInterpreter.h | 52 ------------------- .../mantid/api/src/Exports/FileFinder.cpp | 6 +-- 2 files changed, 3 insertions(+), 55 deletions(-) delete mode 100644 Framework/PythonInterface/inc/MantidPythonInterface/kernel/Environment/ReleaseGlobalInterpreter.h diff --git a/Framework/PythonInterface/inc/MantidPythonInterface/kernel/Environment/ReleaseGlobalInterpreter.h b/Framework/PythonInterface/inc/MantidPythonInterface/kernel/Environment/ReleaseGlobalInterpreter.h deleted file mode 100644 index 2fa489eba19..00000000000 --- a/Framework/PythonInterface/inc/MantidPythonInterface/kernel/Environment/ReleaseGlobalInterpreter.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef MANTID_PYTHONINTERFACE_RELEASEGLOBALINTERPRETER_H_ -#define MANTID_PYTHONINTERFACE_RELEASEGLOBALINTERPRETER_H_ - -#include "MantidPythonInterface/kernel/DllConfig.h" -#include <boost/python/detail/wrap_python.hpp> - -namespace Mantid { -namespace PythonInterface { -namespace Environment { - -/** - * Defines a structure for releaseing the Python GIL - * using the RAII pattern. This releases the Python GIL - * for the duration of the current scope. - */ -class PYTHON_KERNEL_DLL ReleaseGlobalInterpreter { -public: - /// Default constructor - ReleaseGlobalInterpreter(); - /// Destructor - ~ReleaseGlobalInterpreter(); - -private: - // Stores the current python trace used to track where in - // a python script you are. - Py_tracefunc m_tracefunc; - PyObject *m_tracearg; - /// Saved thread state - PyThreadState *m_saved; -}; - -ReleaseGlobalInterpreter::ReleaseGlobalInterpreter() - : m_tracefunc(nullptr), m_tracearg(nullptr), m_saved(nullptr) { - PyThreadState *curThreadState = PyThreadState_GET(); - m_tracefunc = curThreadState->c_tracefunc; - m_tracearg = curThreadState->c_traceobj; - Py_XINCREF(m_tracearg); - PyEval_SetTrace(nullptr, nullptr); - m_saved = PyEval_SaveThread(); -} - -ReleaseGlobalInterpreter::~ReleaseGlobalInterpreter() { - PyEval_RestoreThread(m_saved); - PyEval_SetTrace(m_tracefunc, m_tracearg); - Py_XDECREF(m_tracearg); -} - -} // namespace Environment -} // namespace PythonInterface -} // namespace Mantid - -#endif /* MANTID_PYTHONINTERFACE_RELEASEGLOBALINTERPRETER_H_ */ diff --git a/Framework/PythonInterface/mantid/api/src/Exports/FileFinder.cpp b/Framework/PythonInterface/mantid/api/src/Exports/FileFinder.cpp index c855e8d3615..73b769c2b9d 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/FileFinder.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/FileFinder.cpp @@ -1,6 +1,6 @@ #include "MantidAPI/FileFinder.h" #include "MantidKernel/WarningSuppressions.h" -#include "MantidPythonInterface/kernel/Environment/ReleaseGlobalInterpreter.h" +#include "MantidPythonInterface/kernel/Environment/ReleaseGlobalInterpreterLock.h" #include <boost/python/class.hpp> #include <boost/python/overloads.hpp> #include <boost/python/reference_existing_object.hpp> @@ -33,8 +33,8 @@ std::vector<std::string> runFinderProxy(FileFinderImpl &self, // drop the Python threadstate and reset anything installed // via PyEval_SetTrace while we execute the C++ code - // ReleaseGlobalInterpreter does this for us - Mantid::PythonInterface::Environment::ReleaseGlobalInterpreter - releaseGlobalInterpreter; + Mantid::PythonInterface::Environment::ReleaseGlobalInterpreterLock + releaseGlobalInterpreterLock; return self.findRuns(hinstr); } -- GitLab