Salome HOME
Debug + makes the remote python nodes //
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 6 Aug 2014 11:44:22 +0000 (13:44 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 6 Aug 2014 11:44:22 +0000 (13:44 +0200)
src/runtime/AutoGIL.hxx [new file with mode: 0644]
src/runtime/CMakeLists.txt
src/runtime/DistributedPythonNode.cxx
src/runtime/PythonNode.cxx
src/runtime/SalomeContainerTools.cxx

diff --git a/src/runtime/AutoGIL.hxx b/src/runtime/AutoGIL.hxx
new file mode 100644 (file)
index 0000000..c10df18
--- /dev/null
@@ -0,0 +1,41 @@
+// Copyright (C) 2006-2014  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __AUTOGIL_HXX__
+#define __AUTOGIL_HXX__
+
+#include "Exception.hxx"
+#include <Python.h>
+
+namespace YACS
+{
+  namespace ENGINE
+  {
+    class AutoGIL
+    {
+    public:
+      AutoGIL():_gstate(PyGILState_Ensure()) { }
+      ~AutoGIL() { PyGILState_Release(_gstate); }
+    private:
+      PyGILState_STATE _gstate;
+    };
+  }
+}
+
+#endif
index e7eee373bf5c8bd496e45a2767bde2aab05a5896..1e3048d3ee335e067c0a6205cdcc99bb732de3e1 100644 (file)
@@ -82,6 +82,7 @@ SET(_link_LIBRARIES
 
 SET(YACSRuntimeSALOME_HEADERS
   YACSRuntimeSALOMEExport.hxx 
+  AutoGIL.hxx
   CalStreamPort.hxx
   CORBAComponent.hxx
   CORBACORBAConv.hxx
index 70f9785c2ee7fdbafc4200687e92e5445214820a..3ea734991a95f296ab0310f1927da9b336b9e20a 100644 (file)
@@ -23,6 +23,7 @@
 #include "PythonNode.hxx"
 #include "SalomeHPContainer.hxx"
 #include "SalomeContainerTmpForHP.hxx"
+#include "AutoGIL.hxx"
 
 #include "PythonPorts.hxx"
 #include "YacsTrace.hxx"
@@ -52,67 +53,60 @@ DistributedPythonNode::DistributedPythonNode(const DistributedPythonNode& other,
 
 DistributedPythonNode::~DistributedPythonNode()
 {
-  PyGILState_STATE gstate = PyGILState_Ensure();
+  AutoGIL agil;
   Py_DECREF(_context);
-  PyGILState_Release(gstate);
 }
 
 void DistributedPythonNode::load()
 {
   ServerNode::load();
-  PyGILState_STATE gstate = PyGILState_Ensure();
-  if( PyDict_SetItemString( _context, "__builtins__", getSALOMERuntime()->getBuiltins() ))
-    {
-      stringstream msg;
-      msg << "Impossible to set builtins" << __FILE__ << ":" << __LINE__;
-      PyGILState_Release(gstate);
-      _errorDetails=msg.str();
-      throw Exception(msg.str());
-    }
-  const char picklizeScript[]="import cPickle\ndef pickleForDistPyth2009(*args,**kws):\n  return cPickle.dumps((args,kws),-1)\n\ndef unPickleForDistPyth2009(st):\n  args=cPickle.loads(st)\n  return args\n";
-  PyObject *res=PyRun_String(picklizeScript,Py_file_input,_context,_context);
-  if(res == NULL)
-    {
-      _errorDetails="";
-      PyObject* new_stderr = newPyStdOut(_errorDetails);
-      PySys_SetObject((char*)"stderr", new_stderr);
-      PyErr_Print();
-      PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
-      Py_DECREF(new_stderr);
-
-      PyGILState_Release(gstate);
-      throw Exception("Error during execution");
-      return;
-    }
-  Py_DECREF(res);
-  _pyfuncSer=PyDict_GetItemString(_context,"pickleForDistPyth2009");
-  _pyfuncUnser=PyDict_GetItemString(_context,"unPickleForDistPyth2009");
-  if(_pyfuncSer == NULL)
-    {
-      _errorDetails="";
-      PyObject* new_stderr = newPyStdOut(_errorDetails);
-      PySys_SetObject((char*)"stderr", new_stderr);
-      PyErr_Print();
-      PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
-      Py_DECREF(new_stderr);
-
-      PyGILState_Release(gstate);
-      throw Exception("Error during execution");
-    }
-  if(_pyfuncUnser == NULL)
-    {
-      _errorDetails="";
-      PyObject* new_stderr = newPyStdOut(_errorDetails);
-      PySys_SetObject((char*)"stderr", new_stderr);
-      PyErr_Print();
-      PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
-      Py_DECREF(new_stderr);
-
-      PyGILState_Release(gstate);
-      throw Exception("Error during execution");
-    }
-  DEBTRACE( "---------------End PyfuncSerNode::load function---------------" );
-  PyGILState_Release(gstate);
+  {
+    AutoGIL agil;
+    if( PyDict_SetItemString( _context, "__builtins__", getSALOMERuntime()->getBuiltins() ))
+      {
+        stringstream msg;
+        msg << "Impossible to set builtins" << __FILE__ << ":" << __LINE__;
+        _errorDetails=msg.str();
+        throw Exception(msg.str());
+      }
+    const char picklizeScript[]="import cPickle\ndef pickleForDistPyth2009(*args,**kws):\n  return cPickle.dumps((args,kws),-1)\n\ndef unPickleForDistPyth2009(st):\n  args=cPickle.loads(st)\n  return args\n";
+    PyObject *res=PyRun_String(picklizeScript,Py_file_input,_context,_context);
+    if(res == NULL)
+      {
+        _errorDetails="";
+        PyObject* new_stderr = newPyStdOut(_errorDetails);
+        PySys_SetObject((char*)"stderr", new_stderr);
+        PyErr_Print();
+        PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
+        Py_DECREF(new_stderr);
+        throw Exception("Error during execution");
+        return;
+      }
+    Py_DECREF(res);
+    _pyfuncSer=PyDict_GetItemString(_context,"pickleForDistPyth2009");
+    _pyfuncUnser=PyDict_GetItemString(_context,"unPickleForDistPyth2009");
+    if(_pyfuncSer == NULL)
+      {
+        _errorDetails="";
+        PyObject* new_stderr = newPyStdOut(_errorDetails);
+        PySys_SetObject((char*)"stderr", new_stderr);
+        PyErr_Print();
+        PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
+        Py_DECREF(new_stderr);
+        throw Exception("Error during execution");
+      }
+    if(_pyfuncUnser == NULL)
+      {
+        _errorDetails="";
+        PyObject* new_stderr = newPyStdOut(_errorDetails);
+        PySys_SetObject((char*)"stderr", new_stderr);
+        PyErr_Print();
+        PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
+        Py_DECREF(new_stderr);
+        throw Exception("Error during execution");
+      }
+    DEBTRACE( "---------------End PyfuncSerNode::load function---------------" );
+  }
 }
 
 void DistributedPythonNode::execute()
@@ -141,40 +135,43 @@ void DistributedPythonNode::execute()
     PyObject* ob;
     if(!_pyfuncSer)
       throw Exception("DistributedPythonNode badly loaded");
-    PyGILState_STATE gstate = PyGILState_Ensure();
-    
-    DEBTRACE( "---------------DistributedPythonNode::inputs---------------" );
-    PyObject* args = PyTuple_New(getNumberOfInputPorts()) ;
-    list<InputPort *>::iterator iter2;
-    for(iter2 = _setOfInputPort.begin(); iter2 != _setOfInputPort.end(); iter2++)
-      {
-        InputPyPort *p=(InputPyPort *)*iter2;
-        ob=p->getPyObj();
-        Py_INCREF(ob);
-        PyTuple_SetItem(args,pos,ob);
-        pos++;
-      }
-    PyObject *serializationInput=PyObject_CallObject(_pyfuncSer,args);
-    std::string serializationInputC=PyString_AsString(serializationInput);
-    Engines::pickledArgs *serializationInputCorba=new Engines::pickledArgs;
-    int len=serializationInputC.length();
-    serializationInputCorba->length(serializationInputC.length());
-    for(int i=0;i<serializationInputC.length();i++)
-      (*serializationInputCorba)[i]=serializationInputC[i];
+    Engines::pickledArgs *serializationInputCorba(0);
+    PyObject *args(0);
+    {
+        AutoGIL agil;
+
+        DEBTRACE( "---------------DistributedPythonNode::inputs---------------" );
+        args = PyTuple_New(getNumberOfInputPorts()) ;
+        list<InputPort *>::iterator iter2;
+        for(iter2 = _setOfInputPort.begin(); iter2 != _setOfInputPort.end(); iter2++)
+          {
+            InputPyPort *p=(InputPyPort *)*iter2;
+            ob=p->getPyObj();
+            Py_INCREF(ob);
+            PyTuple_SetItem(args,pos,ob);
+            pos++;
+          }
+        PyObject *serializationInput=PyObject_CallObject(_pyfuncSer,args);
+        std::string serializationInputC=PyString_AsString(serializationInput);
+        serializationInputCorba=new Engines::pickledArgs;
+        int len=serializationInputC.length();
+        serializationInputCorba->length(serializationInputC.length());
+        for(int i=0;i<serializationInputC.length();i++)
+          (*serializationInputCorba)[i]=serializationInputC[i];
+    }
     //serializationInputCorba[serializationInputC.length()]='\0';
     DEBTRACE( "-----------------DistributedPythonNode starting remote python invocation-----------------" );
     Engines::pickledArgs *resultCorba;
     try
-      {
+    {
         resultCorba=pn->execute(getFname().c_str(),*serializationInputCorba);
-      }
+    }
     catch(...)
-      {
+    {
         std::string msg="Exception on remote python invocation";
-        PyGILState_Release(gstate);
         _errorDetails=msg;
         throw Exception(msg);
-      }
+    }
     DEBTRACE( "-----------------DistributedPythonNode end of remote python invocation-----------------" );
     //
     delete serializationInputCorba;
@@ -183,52 +180,52 @@ void DistributedPythonNode::execute()
     for(int i=0;i<resultCorba->length();i++)
       resultCorbaC[i]=(*resultCorba)[i];
     delete resultCorba;
-    args = PyTuple_New(1);
-    PyObject* resultPython=PyString_FromString(resultCorbaC);
-    delete [] resultCorbaC;
-    PyTuple_SetItem(args,0,resultPython);
-    PyObject *finalResult=PyObject_CallObject(_pyfuncUnser,args);
-    DEBTRACE( "-----------------DistributedPythonNode::outputs-----------------" );
-    int nres=1;
-    if(finalResult == Py_None)
-      nres=0;
-    else if(PyTuple_Check(finalResult))
-      nres=PyTuple_Size(finalResult);
-    
-    if(getNumberOfOutputPorts() != nres)
-      {
-        std::string msg="Number of output arguments : Mismatch between definition and execution";
-        Py_DECREF(finalResult);
-        PyGILState_Release(gstate);
-        _errorDetails=msg;
-        throw Exception(msg);
-      }
-    
-    pos=0;
-    list<OutputPort *>::iterator iter;
-    try
+    {
+      AutoGIL agil;
+      args = PyTuple_New(1);
+      PyObject* resultPython=PyString_FromString(resultCorbaC);
+      delete [] resultCorbaC;
+      PyTuple_SetItem(args,0,resultPython);
+      PyObject *finalResult=PyObject_CallObject(_pyfuncUnser,args);
+      DEBTRACE( "-----------------DistributedPythonNode::outputs-----------------" );
+      int nres=1;
+      if(finalResult == Py_None)
+        nres=0;
+      else if(PyTuple_Check(finalResult))
+        nres=PyTuple_Size(finalResult);
+
+      if(getNumberOfOutputPorts() != nres)
+        {
+          std::string msg="Number of output arguments : Mismatch between definition and execution";
+          Py_DECREF(finalResult);
+          _errorDetails=msg;
+          throw Exception(msg);
+        }
+
+      pos=0;
+      list<OutputPort *>::iterator iter;
+      try
       {
-        for(iter = _setOfOutputPort.begin(); iter != _setOfOutputPort.end(); iter++)
-          {
-            OutputPyPort *p=(OutputPyPort *)*iter;
-            DEBTRACE( "port name: " << p->getName() );
-            DEBTRACE( "port kind: " << p->edGetType()->kind() );
-            DEBTRACE( "port pos : " << pos );
-            if(PyTuple_Check(finalResult))ob=PyTuple_GetItem(finalResult,pos) ;
-            else ob=finalResult;
-            DEBTRACE( "ob refcnt: " << ob->ob_refcnt );
-            p->put(ob);
-            pos++;
-          }
+          for(iter = _setOfOutputPort.begin(); iter != _setOfOutputPort.end(); iter++)
+            {
+              OutputPyPort *p=(OutputPyPort *)*iter;
+              DEBTRACE( "port name: " << p->getName() );
+              DEBTRACE( "port kind: " << p->edGetType()->kind() );
+              DEBTRACE( "port pos : " << pos );
+              if(PyTuple_Check(finalResult))ob=PyTuple_GetItem(finalResult,pos) ;
+              else ob=finalResult;
+              DEBTRACE( "ob refcnt: " << ob->ob_refcnt );
+              p->put(ob);
+              pos++;
+            }
       }
-    catch(ConversionException& ex)
+      catch(ConversionException& ex)
       {
-        Py_DECREF(finalResult);
-        PyGILState_Release(gstate);
-        _errorDetails=ex.what();
-        throw;
+          Py_DECREF(finalResult);
+          _errorDetails=ex.what();
+          throw;
       }
-    PyGILState_Release(gstate);
+    }
   }
   DEBTRACE( "++++++++++++++ End DistributedPythonNode::execute: " << getName() << " ++++++++++++++++++++" );
 }
@@ -254,9 +251,8 @@ ServerNode *DistributedPythonNode::createNode(const std::string& name) const
 void DistributedPythonNode::initMySelf()
 {
   _implementation = DistributedPythonNode::IMPL_NAME;
-  PyGILState_STATE gstate=PyGILState_Ensure();
+  AutoGIL agil;
   _context=PyDict_New();
-  PyGILState_Release(gstate);
 }
 
 void DistributedPythonNode::dealException(CORBA::Exception *exc, const char *method, const char *ref)
index bd33fbd14b6b1b952222d363c2a4368afe037f65..b82e20d70d4af39f0e1bfd64507fdd8718ff18d4 100644 (file)
 #include "PythonNode.hxx"
 #include "PythonPorts.hxx"
 #include "TypeCode.hxx"
+#include "AutoGIL.hxx"
 #include "Container.hxx"
 #include "SalomeContainer.hxx"
+#include "SalomeHPContainer.hxx"
+#include "SalomeContainerTmpForHP.hxx"
 #include "ConversionException.hxx"
 
 #include "PyStdout.hxx"
@@ -153,7 +156,23 @@ void PythonNode::loadRemote()
       throw Exception(what);
     }
 
-  Engines::Container_var objContainer=((SalomeContainer*)_container)->getContainerPtr(this);
+
+  Engines::Container_var objContainer=Engines::Container::_nil();
+  if(!_container)
+    throw Exception("No container specified !");
+  SalomeContainer *containerCast0(dynamic_cast<SalomeContainer *>(_container));
+  SalomeHPContainer *containerCast1(dynamic_cast<SalomeHPContainer *>(_container));
+  if(containerCast0)
+    objContainer=containerCast0->getContainerPtr(this);
+  else if(containerCast1)
+    {
+      YACS::BASES::AutoCppPtr<SalomeContainerTmpForHP> tmpCont(SalomeContainerTmpForHP::BuildFrom(containerCast1,this));
+      objContainer=tmpCont->getContainerPtr(this);
+    }
+  else
+    throw Exception("Unrecognized type of container ! Salome one is expected for PythonNode !");
+  if(CORBA::is_nil(objContainer))
+    throw Exception("Container corba pointer is NULL for PythonNode !");
 
   try
     {
@@ -658,7 +677,23 @@ void PyFuncNode::loadRemote()
       throw Exception(what);
     }
 
-  Engines::Container_var objContainer=((SalomeContainer*)_container)->getContainerPtr(this);
+  Engines::Container_var objContainer=Engines::Container::_nil();
+  if(!_container)
+    throw Exception("No container specified !");
+  SalomeContainer *containerCast0(dynamic_cast<SalomeContainer *>(_container));
+  SalomeHPContainer *containerCast1(dynamic_cast<SalomeHPContainer *>(_container));
+  if(containerCast0)
+    objContainer=containerCast0->getContainerPtr(this);
+  else if(containerCast1)
+    {
+      YACS::BASES::AutoCppPtr<SalomeContainerTmpForHP> tmpCont(SalomeContainerTmpForHP::BuildFrom(containerCast1,this));
+      objContainer=tmpCont->getContainerPtr(this);
+    }
+  else
+    throw Exception("Unrecognized type of container ! Salome one is expected ! In PythonNode !");
+  if(CORBA::is_nil(objContainer))
+    throw Exception("Container corba pointer is NULL ! In PythonNode !");
+
   try
     {
       _pynode = objContainer->createPyNode(getName().c_str(),getScript().c_str());
@@ -672,57 +707,52 @@ void PyFuncNode::loadRemote()
       throw Exception(msg);
     }
 
-  PyGILState_STATE gstate = PyGILState_Ensure();
-  const char picklizeScript[]="import cPickle\n"
-                              "def pickleForDistPyth2009(*args,**kws):\n"
-                              "  return cPickle.dumps((args,kws),-1)\n"
-                              "\n"
-                              "def unPickleForDistPyth2009(st):\n"
-                              "  args=cPickle.loads(st)\n"
-                              "  return args\n";
-  PyObject *res=PyRun_String(picklizeScript,Py_file_input,_context,_context);
-  if(res == NULL)
-    {
-      _errorDetails="";
-      PyObject* new_stderr = newPyStdOut(_errorDetails);
-      PySys_SetObject((char*)"stderr", new_stderr);
-      PyErr_Print();
-      PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
-      Py_DECREF(new_stderr);
-
-      PyGILState_Release(gstate);
-      throw Exception("Error during load");
-    }
-  Py_DECREF(res);
-
-  _pyfuncSer=PyDict_GetItemString(_context,"pickleForDistPyth2009");
-  _pyfuncUnser=PyDict_GetItemString(_context,"unPickleForDistPyth2009");
-  if(_pyfuncSer == NULL)
-    {
-      _errorDetails="";
-      PyObject* new_stderr = newPyStdOut(_errorDetails);
-      PySys_SetObject((char*)"stderr", new_stderr);
-      PyErr_Print();
-      PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
-      Py_DECREF(new_stderr);
-
-      PyGILState_Release(gstate);
-      throw Exception("Error during load");
-    }
-  if(_pyfuncUnser == NULL)
-    {
-      _errorDetails="";
-      PyObject* new_stderr = newPyStdOut(_errorDetails);
-      PySys_SetObject((char*)"stderr", new_stderr);
-      PyErr_Print();
-      PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
-      Py_DECREF(new_stderr);
-
-      PyGILState_Release(gstate);
-      throw Exception("Error during load");
-    }
-  DEBTRACE( "---------------End PyfuncNode::loadRemote function---------------" );
-  PyGILState_Release(gstate);
+  {
+    AutoGIL agil;
+    const char picklizeScript[]="import cPickle\n"
+        "def pickleForDistPyth2009(*args,**kws):\n"
+        "  return cPickle.dumps((args,kws),-1)\n"
+        "\n"
+        "def unPickleForDistPyth2009(st):\n"
+        "  args=cPickle.loads(st)\n"
+        "  return args\n";
+    PyObject *res=PyRun_String(picklizeScript,Py_file_input,_context,_context);
+    if(res == NULL)
+      {
+        _errorDetails="";
+        PyObject* new_stderr = newPyStdOut(_errorDetails);
+        PySys_SetObject((char*)"stderr", new_stderr);
+        PyErr_Print();
+        PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
+        Py_DECREF(new_stderr);
+        throw Exception("Error during load");
+      }
+    Py_DECREF(res);
+
+    _pyfuncSer=PyDict_GetItemString(_context,"pickleForDistPyth2009");
+    _pyfuncUnser=PyDict_GetItemString(_context,"unPickleForDistPyth2009");
+    if(_pyfuncSer == NULL)
+      {
+        _errorDetails="";
+        PyObject* new_stderr = newPyStdOut(_errorDetails);
+        PySys_SetObject((char*)"stderr", new_stderr);
+        PyErr_Print();
+        PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
+        Py_DECREF(new_stderr);
+        throw Exception("Error during load");
+      }
+    if(_pyfuncUnser == NULL)
+      {
+        _errorDetails="";
+        PyObject* new_stderr = newPyStdOut(_errorDetails);
+        PySys_SetObject((char*)"stderr", new_stderr);
+        PyErr_Print();
+        PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
+        Py_DECREF(new_stderr);
+        throw Exception("Error during load");
+      }
+    DEBTRACE( "---------------End PyfuncNode::loadRemote function---------------" );
+  }
 }
 
 void PyFuncNode::loadLocal()
@@ -814,37 +844,35 @@ void PyFuncNode::executeRemote()
   DEBTRACE( "++++++++++++++ PyFuncNode::executeRemote: " << getName() << " ++++++++++++++++++++" );
   if(!_pyfuncSer)
     throw Exception("DistributedPythonNode badly loaded");
-  PyGILState_STATE gstate = PyGILState_Ensure();
-
-  //===========================================================================
-  // Get inputs in input ports, build a Python tuple and pickle it
-  //===========================================================================
-  PyObject* ob;
-  PyObject* args = PyTuple_New(getNumberOfInputPorts());
-  std::list<InputPort *>::iterator iter2;
-  int pos=0;
-  for(iter2 = _setOfInputPort.begin(); iter2 != _setOfInputPort.end(); ++iter2)
-    {
-      InputPyPort *p=(InputPyPort *)*iter2;
-      ob=p->getPyObj();
-      Py_INCREF(ob);
-      PyTuple_SetItem(args,pos,ob);
-      pos++;
-    }
+  Py_ssize_t len;
+  char *serializationInputC(0);
+  PyObject *args(0),*ob(0);
+  int pos(0);
+  {
+      AutoGIL agil;
+
+      //===========================================================================
+      // Get inputs in input ports, build a Python tuple and pickle it
+      //===========================================================================
+      args = PyTuple_New(getNumberOfInputPorts());
+      std::list<InputPort *>::iterator iter2;
+      for(iter2 = _setOfInputPort.begin(); iter2 != _setOfInputPort.end(); ++iter2)
+        {
+          InputPyPort *p=(InputPyPort *)*iter2;
+          ob=p->getPyObj();
+          Py_INCREF(ob);
+          PyTuple_SetItem(args,pos,ob);
+          pos++;
+        }
 #ifdef _DEVDEBUG_
-  PyObject_Print(args,stderr,Py_PRINT_RAW);
-  std::cerr << endl;
+      PyObject_Print(args,stderr,Py_PRINT_RAW);
+      std::cerr << endl;
 #endif
-  PyObject *serializationInput=PyObject_CallObject(_pyfuncSer,args);
-  //The pickled string may contain NULL characters so use PyString_AsStringAndSize
-  char* serializationInputC;
-  Py_ssize_t len;
-  if (PyString_AsStringAndSize(serializationInput, &serializationInputC, &len))
-    {
-      PyGILState_Release(gstate);
-      throw Exception("DistributedPythonNode problem in python pickle");
-    }
-  PyGILState_Release(gstate);
+      PyObject *serializationInput=PyObject_CallObject(_pyfuncSer,args);
+      //The pickled string may contain NULL characters so use PyString_AsStringAndSize
+      if (PyString_AsStringAndSize(serializationInput, &serializationInputC, &len))
+        throw Exception("DistributedPythonNode problem in python pickle");
+  }
 
   Engines::pickledArgs_var serializationInputCorba=new Engines::pickledArgs;
   serializationInputCorba->length(len);
@@ -877,60 +905,58 @@ void PyFuncNode::executeRemote()
   for(int i=0;i<resultCorba->length();i++)
     resultCorbaC[i]=resultCorba[i];
 
-  gstate = PyGILState_Ensure();
-
-  PyObject* resultPython=PyString_FromStringAndSize(resultCorbaC,resultCorba->length());
-  delete [] resultCorbaC;
-  args = PyTuple_New(1);
-  PyTuple_SetItem(args,0,resultPython);
-  PyObject *finalResult=PyObject_CallObject(_pyfuncUnser,args);
-  Py_DECREF(args);
-
-  DEBTRACE( "-----------------PythonNode::outputs-----------------" );
-  int nres=1;
-  if(finalResult == Py_None)
-    nres=0;
-  else if(PyTuple_Check(finalResult))
-    nres=PyTuple_Size(finalResult);
-
-  if(getNumberOfOutputPorts() != nres)
-    {
-      std::string msg="Number of output arguments : Mismatch between definition and execution";
-      Py_DECREF(finalResult);
-      PyGILState_Release(gstate);
-      _errorDetails=msg;
-      throw Exception(msg);
-    }
-
-  pos=0;
-  std::list<OutputPort *>::iterator iter;
-  try
-    {
-      for(iter = _setOfOutputPort.begin(); iter != _setOfOutputPort.end(); ++iter)
+  {
+      AutoGIL agil;
+
+      PyObject* resultPython=PyString_FromStringAndSize(resultCorbaC,resultCorba->length());
+      delete [] resultCorbaC;
+      args = PyTuple_New(1);
+      PyTuple_SetItem(args,0,resultPython);
+      PyObject *finalResult=PyObject_CallObject(_pyfuncUnser,args);
+      Py_DECREF(args);
+
+      DEBTRACE( "-----------------PythonNode::outputs-----------------" );
+      int nres=1;
+      if(finalResult == Py_None)
+        nres=0;
+      else if(PyTuple_Check(finalResult))
+        nres=PyTuple_Size(finalResult);
+
+      if(getNumberOfOutputPorts() != nres)
         {
-          OutputPyPort *p=(OutputPyPort *)*iter;
-          DEBTRACE( "port name: " << p->getName() );
-          DEBTRACE( "port kind: " << p->edGetType()->kind() );
-          DEBTRACE( "port pos : " << pos );
-          if(PyTuple_Check(finalResult))
-            ob=PyTuple_GetItem(finalResult,pos) ;
-          else 
-            ob=finalResult;
-          DEBTRACE( "ob refcnt: " << ob->ob_refcnt );
-          p->put(ob);
-          pos++;
+          std::string msg="Number of output arguments : Mismatch between definition and execution";
+          Py_DECREF(finalResult);
+          _errorDetails=msg;
+          throw Exception(msg);
         }
-      Py_DECREF(finalResult);
-    }
-  catch(ConversionException& ex)
-    {
-      Py_DECREF(finalResult);
-      PyGILState_Release(gstate);
-      _errorDetails=ex.what();
-      throw;
-    }
 
-  PyGILState_Release(gstate);
+      pos=0;
+      std::list<OutputPort *>::iterator iter;
+      try
+      {
+          for(iter = _setOfOutputPort.begin(); iter != _setOfOutputPort.end(); ++iter)
+            {
+              OutputPyPort *p=(OutputPyPort *)*iter;
+              DEBTRACE( "port name: " << p->getName() );
+              DEBTRACE( "port kind: " << p->edGetType()->kind() );
+              DEBTRACE( "port pos : " << pos );
+              if(PyTuple_Check(finalResult))
+                ob=PyTuple_GetItem(finalResult,pos) ;
+              else
+                ob=finalResult;
+              DEBTRACE( "ob refcnt: " << ob->ob_refcnt );
+              p->put(ob);
+              pos++;
+            }
+          Py_DECREF(finalResult);
+      }
+      catch(ConversionException& ex)
+      {
+          Py_DECREF(finalResult);
+          _errorDetails=ex.what();
+          throw;
+      }
+  }
 
   DEBTRACE( "++++++++++++++ ENDOF PyFuncNode::executeRemote: " << getName() << " ++++++++++++++++++++" );
 }
index 1a8ed785658587fd4287fa16ca412c28e1b9585e..360e67eb18cf69b226debbc8ade9f4011fbe216b 100644 (file)
@@ -347,7 +347,7 @@ void SalomeContainerTools::Start(const std::vector<std::string>& compoNames, Sal
     {
       shutdownLevel=1;
     }
-  sct.setContainerName(str);
+  //sct.setContainerName(str);
   SetContainerNameOf(myparams,str);
   Engines::Container_var trueCont(Engines::Container::_nil());
   if(!isEmptyName && shutdownLevel==999)