From 6ae747674e7b1c8f8584eb47b64f7e78253bbbdb Mon Sep 17 00:00:00 2001 From: prascle Date: Fri, 7 Jul 2006 10:08:54 +0000 Subject: [PATCH] PR: for 9772 (avoid deadlock with embedded python container) --- src/LifeCycleCORBA_SWIG/Makefile.am | 2 +- .../libSALOME_LifeCycleCORBA.i | 77 +++++++++++++++---- 2 files changed, 63 insertions(+), 16 deletions(-) diff --git a/src/LifeCycleCORBA_SWIG/Makefile.am b/src/LifeCycleCORBA_SWIG/Makefile.am index 0a1b1d8b4..b6e9dbebb 100644 --- a/src/LifeCycleCORBA_SWIG/Makefile.am +++ b/src/LifeCycleCORBA_SWIG/Makefile.am @@ -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 diff --git a/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i b/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i index c8bbe000b..29d6de464 100644 --- a/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i +++ b/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i @@ -19,14 +19,22 @@ // +// ---------------------------------------------------------------------------- + %module libSALOME_LifeCycleCORBA +%include + + +// ---------------------------------------------------------------------------- + %{ #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 + +%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< +%include + -- 2.39.2