return !_imposedResource.empty() && !_imposedContainer.empty();
}
+bool PythonEntry::IsProxy( PyObject *ob )
+{
+ if(!_pyClsBigObject)
+ return false;
+ return PyObject_IsInstance( ob, _pyClsBigObject) == 1;
+}
+
bool PythonEntry::GetDestroyStatus( PyObject *ob )
{
if(!_pyClsBigObject)
DEBTRACE( "++++++++++++++ PyNode::executeLocal: " << getName() << " ++++++++++++++++++++" );
{
AutoGIL agil;
- std::ostringstream unpxy; unpxy << "from SALOME_PyNode import UnProxyObjectSimple" << std::endl;
+ std::ostringstream unpxy; unpxy << "from SALOME_PyNode import UnProxyObjectSimpleLocal" << std::endl;
DEBTRACE( "---------------PyNode::inputs---------------" );
list<InputPort *>::iterator iter2;
for(iter2 = _setOfInputPort.begin(); iter2 != _setOfInputPort.end(); iter2++)
DEBTRACE( "port name: " << p->getName() );
DEBTRACE( "port kind: " << p->edGetType()->kind() );
PyObject* ob=p->getPyObj();
- DEBTRACE( "ob refcnt: " << ob->ob_refcnt );
- unpxy << p->getName() << " = UnProxyObjectSimple( " << p->getName() << " )" << std::endl;
+ DEBTRACE( "ob refcnt: " << ob->ob_refcnt );
+ unpxy << p->getName() << " = UnProxyObjectSimpleLocal( " << p->getName() << " )" << std::endl;
#ifdef _DEVDEBUG_
PyObject_Print(ob,stderr,Py_PRINT_RAW);
cerr << endl;
class YACSRUNTIMESALOME_EXPORT PythonEntry
{
public:
+ static bool IsProxy( PyObject *ob );
/*! return true only if ob is a proxy and destroy flag set to true*/
static bool GetDestroyStatus( PyObject *ob );
static void DoNotTouchFileIfProxy( PyObject *ob );
static void UnlinkOnDestructorIfProxy( PyObject *ob );
+ static void IfProxyDoSomething( PyObject *ob, const char *meth );
protected:
PythonEntry();
~PythonEntry();
void loadRemoteContext(InlineNode *reqNode, Engines::Container_ptr objContainer, bool isInitializeRequested);
static std::string GetContainerLog(const std::string& mode, Container *container, const Task *askingTask);
virtual bool hasImposedResource()const;
- static void IfProxyDoSomething( PyObject *ob, const char *meth );
protected:
PyObject *_context;
PyObject *_pyfuncSer;
using namespace YACS::ENGINE;
using namespace std;
-void releasePyObj(PyObject* data)
+static void RegisterReleasePyObj(PyObject* data, const char *method1)
{
if(!data)
return ;
{
if(PyLong_AS_LONG(result))
{
- PyObject* o=PyObject_CallMethod(data, (char*)"Destroy", (char*)"");
+ PyObject* o=PyObject_CallMethod(data, (char*)method1, (char*)"");
if(o)
Py_XDECREF( o);
else
}
}
+void releasePyObj(PyObject* data)
+{
+ RegisterReleasePyObj(data,"Destroy");
+}
+
void registerPyObj(PyObject* data)
{
- if (PyObject_HasAttrString(data, (char*)"_is_a"))
- {
- PyObject *result = PyObject_CallMethod(data, (char*)"_is_a", (char*)"s",(char*)"IDL:SALOME/GenericObj:1.0");
- if(result && PyLong_Check(result))
- {
- if(PyLong_AS_LONG(result))
- {
- PyObject* o= PyObject_CallMethod(data, (char*)"Register", (char*)"") ;
- if(o)
- Py_XDECREF( o);
- else
- {
-#ifdef _DEVDEBUG_
- PyErr_Print();
-#else
- PyErr_Clear();
-#endif
- throw ConversionException("Corba object does not exist: you have perhaps forgotten to call Register on a GenericObj");
- }
- }
- Py_XDECREF(result);
- }
- if(!result)
- {
-#ifdef _DEVDEBUG_
- PyErr_Print();
-#else
- PyErr_Clear();
-#endif
- throw ConversionException("Corba object does not exist: you have perhaps forgotten to call Register on a GenericObj");
- }
- }
+ RegisterReleasePyObj(data,"Register");
}
InputPyPort::InputPyPort(const std::string& name, Node *node, TypeCode * type)
PyObject* mod=PyImport_ImportModule("pickle");
PyObject *pickled=PyObject_CallMethod(mod,(char *)"dumps",(char *)"Oi",o,protocol);
if( somthingToDo )
+ {
YACS::ENGINE::PythonEntry::UnlinkOnDestructorIfProxy(o);
+ YACS::ENGINE::PythonEntry::IfProxyDoSomething(o,"incrRef");
+ }
DEBTRACE(PyObject_Repr(pickled) );
Py_DECREF(mod);
if(pickled==NULL)
for(int i=0;i<length;i++)
{
PyObject *item=PySequence_ITEM(o,i);
+ bool somthingToDo = YACS::ENGINE::PythonEntry::IsProxy(item);
+ if( somthingToDo )
+ {
+ YACS::ENGINE::PythonEntry::UnlinkOnDestructorIfProxy(item);
+ YACS::ENGINE::PythonEntry::IfProxyDoSomething(item,"incrRef");
+ }
#ifdef _DEVDEBUG_
std::cerr <<"item[" << i << "]=";
PyObject_Print(item,stderr,Py_PRINT_RAW);
PyObject *ob=PyObject_CallMethod(mod,(char *)"loads",(char *)"y#",o.c_str(),o.length());
DEBTRACE(PyObject_Repr(ob));
Py_DECREF(mod);
+ bool somthingToDo = YACS::ENGINE::PythonEntry::IsProxy(ob);
+ if( somthingToDo )
+ {
+ // no incrRef here because the incrRef has been done before dumps that construct o.
+ YACS::ENGINE::PythonEntry::UnlinkOnDestructorIfProxy(ob);
+ }
if(ob==NULL)
{
PyErr_Print();