]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
[29576] : management of dump state in separate thread
authorAnthony Geay <anthony.geay@edf.fr>
Fri, 23 Feb 2024 17:39:25 +0000 (18:39 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Fri, 23 Feb 2024 17:39:25 +0000 (18:39 +0100)
src/Basics/PythonCppUtils.hxx

index 9050055668d35be50a9787b9cac813ebfd944faf..8a54b86bb7013ea88693b769e8160dcaae036702 100644 (file)
@@ -34,7 +34,7 @@ class AutoPyRef
 {
 public:
   AutoPyRef(PyObject *pyobj=nullptr):_pyobj(pyobj) { }
-  virtual ~AutoPyRef() { release(); }
+  ~AutoPyRef() { release(); }
   AutoPyRef(const AutoPyRef& other):_pyobj(other._pyobj) { if(_pyobj) Py_XINCREF(_pyobj); }
   AutoPyRef(AutoPyRef&& other) = default;
   AutoPyRef& operator=(const AutoPyRef& other) { if(_pyobj==other._pyobj) return *this; release(); _pyobj=other._pyobj; Py_XINCREF(_pyobj); return *this; }
@@ -55,3 +55,12 @@ public:
   AutoPyRefGilSafe(PyObject *pyobj=nullptr):AutoPyRef(pyobj) { }
   ~AutoPyRefGilSafe() { AutoGIL agil; release(); }
 };
+
+class AutoPyYielder
+{
+private:
+  PyThreadState *_save = nullptr;
+public:
+  AutoPyYielder() { _save = PyEval_SaveThread(); }
+  ~AutoPyYielder() { PyEval_RestoreThread(_save); }
+};