--- /dev/null
+// 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
SET(YACSRuntimeSALOME_HEADERS
YACSRuntimeSALOMEExport.hxx
+ AutoGIL.hxx
CalStreamPort.hxx
CORBAComponent.hxx
CORBACORBAConv.hxx
#include "PythonNode.hxx"
#include "SalomeHPContainer.hxx"
#include "SalomeContainerTmpForHP.hxx"
+#include "AutoGIL.hxx"
#include "PythonPorts.hxx"
#include "YacsTrace.hxx"
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()
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;
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() << " ++++++++++++++++++++" );
}
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)
#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"
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
{
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());
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()
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);
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() << " ++++++++++++++++++++" );
}
{
shutdownLevel=1;
}
- sct.setContainerName(str);
+ //sct.setContainerName(str);
SetContainerNameOf(myparams,str);
Engines::Container_var trueCont(Engines::Container::_nil());
if(!isEmptyName && shutdownLevel==999)