]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
PR: for 9772 (avoid deadlock with embedded python container)
authorprascle <prascle>
Fri, 7 Jul 2006 10:08:54 +0000 (10:08 +0000)
committerprascle <prascle>
Fri, 7 Jul 2006 10:08:54 +0000 (10:08 +0000)
src/LifeCycleCORBA_SWIG/Makefile.am
src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i

index 0a1b1d8b48ae0774d0892bfc01d5ab7775b476da..b6e9dbebb54acf7e2ded69827411a72f2dfaf241 100644 (file)
@@ -52,7 +52,7 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am
 
 BUILT_SOURCES = swig_wrap.cpp
 
-SWIG_FLAGS    = @SWIG_FLAGS@ -I$(srcdir) -I$(srcdir)/../LifeCycleCORBA
+SWIG_FLAGS    = @SWIG_FLAGS@ -I$(srcdir) -I$(srcdir)/../LifeCycleCORBA -I$(srcdir)/../Utils
 SWIG_SOURCES  = libSALOME_LifeCycleCORBA.i
 
 pkgpython_PYTHON = libSALOME_LifeCycleCORBA.py
index c8bbe000b8b72ec650b9a975eb1e98ce5ebf1832..29d6de464a6d4faf451c9fff6493223361d15d15 100644 (file)
 //
 
 
+// ----------------------------------------------------------------------------
+
 %module libSALOME_LifeCycleCORBA
 
+%include <std_except.i>
+
+
+// ----------------------------------------------------------------------------
+
 %{
 #include "utilities.h"
 #include "SALOME_LifeCycleCORBA.hxx"
 #include "SALOME_FileTransferCORBA.hxx"
 #include "SALOME_NamingService.hxx"
 #include "ServiceUnreachable.hxx"
+#include "Utils_SALOME_Exception.hxx"
 
   using namespace std;
 
@@ -55,6 +63,9 @@ struct omniORBpyAPI {
 %}
 
 
+// ----------------------------------------------------------------------------
+
+
 %init
 %{
   // init section
@@ -72,20 +83,8 @@ struct omniORBpyAPI {
 %}
 
 
-%exception {
-    try {
-      $action
-    }
-    catch (ServiceUnreachable) {
-      PyErr_SetString(PyExc_RuntimeError,"Naming Service Unreacheable");
-      return NULL;
-    }
-    catch (...) {
-      PyErr_SetString(PyExc_RuntimeError, "unknown exception");
-      return NULL;
-    }
-}
 
+// ----------------------------------------------------------------------------
 
 %typemap(python,out) Engines::Container_ptr, Engines::Component_ptr, Engines::fileRef_ptr
 {
@@ -95,6 +94,20 @@ struct omniORBpyAPI {
   SCRUTE($result);
 }
 
+%typemap(python,in) Engines::fileRef_ptr aFileRef
+{
+  MESSAGE("typemap in on CORBA object ptr");
+  try {
+     CORBA::Object_ptr obj = api->pyObjRefToCxxObjRef($input,1);
+     $1 = Engines::fileRef::_narrow(obj);
+     SCRUTE($1);
+  }
+  catch (...) {
+     PyErr_SetString(PyExc_RuntimeError, "not a valid CORBA object ptr");
+  }
+}
+
+
 %typemap(python,out) std::string, 
                    string
 {
@@ -206,5 +219,39 @@ struct omniORBpyAPI {
   delete $1;
 }
 
-%include "SALOME_LifeCycleCORBA.hxx"
-%include "SALOME_FileTransferCORBA.hxx"
+// ----------------------------------------------------------------------------
+
+%include <Utils_SALOME_Exception.hxx>
+
+%exception {
+    PyThreadState *_save;
+    _save = PyEval_SaveThread();
+    try {
+      $action
+    }
+    catch (ServiceUnreachable) {
+       PyEval_RestoreThread(_save);
+       PyErr_SetString(PyExc_RuntimeError,"Naming Service Unreacheable");
+       return NULL;
+    }
+    catch (SALOME::SALOME_Exception &e) {
+       MESSAGE("catch SALOME exception");
+       //std::ostringstream os; os<<e;
+       PyEval_RestoreThread(_save);
+       //PyErr_SetString(PyExc_RuntimeError,os.str().c_str());
+       //PyErr_SetString(PyExc_RuntimeError,e.what());
+       SWIG_exception(SWIG_RuntimeError,"SALOME exception");
+       return NULL;
+    }
+    catch (...) {
+       PyEval_RestoreThread(_save);
+       PyErr_SetString(PyExc_RuntimeError, "unknown exception");
+       return NULL;
+    }
+    PyEval_RestoreThread(_save);
+}
+
+
+%include <SALOME_LifeCycleCORBA.hxx>
+%include <SALOME_FileTransferCORBA.hxx>
+