Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[samples/component.git] / src / SIGNALSComponent_Swig / libSIGNALSComponent_Swig.i
index 228e62c723e4df348548bb9d3cb7cfb770dce87d..2d329e4adbc1072df1237f6d2604fb6ceaebffc0 100644 (file)
 #include "SIGNALSComponent_Impl.hxx"
 %}
 
+/*
+  managing C++ exception in the Python API
+*/
+%exception
+{
+  class PyAllowThreadsGuard {
+   public:
+    // Py_BEGIN_ALLOW_THREADS
+    PyAllowThreadsGuard() { _save = PyEval_SaveThread(); }
+    // Py_END_ALLOW_THREADS
+    ~PyAllowThreadsGuard() { PyEval_RestoreThread(_save); }
+   private:
+    PyThreadState *_save;
+  };
+
+  PyAllowThreadsGuard guard;
+
+  $action
+}
+
 class SIGNALSComponent_Impl {
 public:
   SIGNALSComponent_Impl(){};