X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2FPythonNode.cxx;h=57a13a016448a21fbd9322d87bd9550823187f5d;hb=d4af5aa95ba95d6e4b301323050ccd0d843d67a8;hp=0010800456e0df12dcfc4fe9a9ecad873889d034;hpb=62ad001a61722b3275cf106414ce6837c85ca036;p=modules%2Fyacs.git diff --git a/src/runtime/PythonNode.cxx b/src/runtime/PythonNode.cxx index 001080045..57a13a016 100644 --- a/src/runtime/PythonNode.cxx +++ b/src/runtime/PythonNode.cxx @@ -332,7 +332,24 @@ bool PythonEntry::IsProxy( PyObject *ob ) { if(!_pyClsBigObject) return false; - return PyObject_IsInstance( ob, _pyClsBigObject) == 1; + if( PyObject_IsInstance( ob, _pyClsBigObject) == 1 ) + { + return true; + } + else + { + if( PyList_Check( ob ) ) + { + auto sz = PyList_Size( ob ); + for( auto i = 0 ; i < sz ; ++i ) + { + PyObject *elt = PyList_GetItem( ob, i ); + if( PythonEntry::IsProxy(elt) ) + return true; + } + } + } + return false; } bool PythonEntry::GetDestroyStatus( PyObject *ob ) @@ -349,6 +366,19 @@ bool PythonEntry::GetDestroyStatus( PyObject *ob ) } return false; } + else + { + if( PyList_Check( ob ) ) + { + auto sz = PyList_Size( ob ); + for( auto i = 0 ; i < sz ; ++i ) + { + PyObject *elt = PyList_GetItem( ob, i ); + if( PythonEntry::GetDestroyStatus(elt) ) + return true; + } + } + } return false; } @@ -361,6 +391,18 @@ void PythonEntry::IfProxyDoSomething( PyObject *ob, const char *meth ) AutoPyRef unlinkOnDestructor = PyObject_GetAttrString(ob,meth); AutoPyRef tmp = PyObject_CallFunctionObjArgs(unlinkOnDestructor,nullptr); } + else + { + if( PyList_Check( ob ) ) + { + auto sz = PyList_Size( ob ); + for( auto i = 0 ; i < sz ; ++i ) + { + PyObject *elt = PyList_GetItem( ob, i ); + PythonEntry::IfProxyDoSomething( elt, meth ); + } + } + } } void PythonEntry::DoNotTouchFileIfProxy( PyObject *ob ) @@ -373,7 +415,8 @@ void PythonEntry::UnlinkOnDestructorIfProxy( PyObject *ob ) IfProxyDoSomething(ob,"unlinkOnDestructor"); } -PythonNode::PythonNode(const PythonNode& other, ComposedNode *father):InlineNode(other,father),_autoSqueeze(other._autoSqueeze) +PythonNode::PythonNode(const PythonNode& other, ComposedNode *father): +InlineNode(other,father),_autoSqueeze(other._autoSqueeze),_nonSqueezableOutputNodes(other._nonSqueezableOutputNodes) { _pynode = Engines::PyScriptNode::_nil(); _implementation=IMPL_NAME; @@ -806,6 +849,16 @@ void PythonNode::executeLocal() DEBTRACE( "++++++++++++++ End PyNode::execute: " << getName() << " ++++++++++++++++++++" ); } +/*! + * [EDF28562] + * \param in squeezeExceptions list on output port name excluded from the squeeze mecanism + */ +void PythonNode::setSqueezeStatusWithExceptions(bool sqStatus, const std::vector& squeezeExceptions) +{ + this->setSqueezeStatus(sqStatus); + this->_nonSqueezableOutputNodes = std::set(squeezeExceptions.begin(), squeezeExceptions.end()); +} + void PythonNode::squeezeMemorySafe() { AutoGIL agil; @@ -826,6 +879,8 @@ void PythonNode::squeezeMemory() } for(auto p : _setOfOutputPort) { + if (!this->_nonSqueezableOutputNodes.empty() && this->_nonSqueezableOutputNodes.find(p->getName()) != this->_nonSqueezableOutputNodes.end()) + continue; PyDict_DelItemString(_context,p->getName().c_str()); OutputPyPort *p2(static_cast(p)); p2->putWithoutForward(Py_None); @@ -842,6 +897,8 @@ void PythonNode::squeezeMemoryRemote() } for(auto p : _setOfOutputPort) { + if (!this->_nonSqueezableOutputNodes.empty() && this->_nonSqueezableOutputNodes.find(p->getName()) != this->_nonSqueezableOutputNodes.end()) + continue; OutputPyPort *p2(static_cast(p)); p2->putWithoutForward(Py_None); }