1 // SUPERV GraphExecutor : contains classes that permit execution of graphs and particularly the execution automaton
3 // Copyright (C) 2003 CEA/DEN, EDF R&D
7 // File : DataFlowExecutor_PyDynInvoke.cxx
8 // Author : Jean Rahuel, CEA
17 #include "DataFlowExecutor_InNode.hxx"
18 #include "DataFlowExecutor_OutNode.hxx"
20 using namespace CORBA ;
22 //static PyObject * MyPyObjSignal = NULL ;
23 static PyObject * MyPyObjRef = NULL ;
24 static PyObject * MyPyObjIor = NULL ;
25 static PyObject * MyPyRunMethod = NULL ;
27 static PyMethodDef MethodPyRunMethod[] = {
28 { "RunMethod", PyRunMethod, METH_VARARGS },
32 bool GraphExecutor::InNode::InitPython() {
33 cdebug_in << "InitPython" << endl ;
35 Automaton()->PyLock() ;
36 // PyObject * Module = Py_InitModule( "InitPyRunMethod" , MethodPyRunMethod ) ;
37 if ( !Automaton()->PyInitModule() ) {
38 // Py_InitModule( "InitPyRunMethod" , MethodPyRunMethod ) ;
39 _OutNode->SuperVisionContainer()->ActivatePythonExecution( "InitPyRunMethod" , MethodPyRunMethod ) ;
41 // PyObject * Dictionnary = PyModule_GetDict( Module ) ;
42 // InitPyDynInvokeError = PyErr_NewException( "InitPyDynInvokeError" , NULL , NULL ) ;
43 // PyDict_SetItemString( Dictionnary , InitPyDynInvokeError ) ;
44 cdebug << ThreadNo() << "Py_Initialized() " << endl ;
47 //JR : Python documentation says that there is no sense to set a handler of synchronous
48 // signals as SIGSEGV and SIGFPE !!!
49 if ( Automaton()->PyFunction( "PyObjSignal" ) == NULL ) {
51 aPyFunc = "import signal\n" ;
52 aPyFunc += "import InitPyRunMethod\n" ;
53 aPyFunc += "import sys\n" ;
54 aPyFunc += "import CORBA\n" ;
55 aPyFunc += "import omniORB\n" ;
56 aPyFunc += "def PySignalHandler( aSignal , aStackFrame ) :\n" ;
57 aPyFunc += " print 'PySignalHandler(aSignal =',aSignal,',aStackFrame= ',aStackFrame,')'\n" ;
58 aPyFunc += "InitPyRunMethod.RunMethod( PySignalHandler )\n" ;
59 aPyFunc += "PrevHandler = signal.signal( signal.SIGSEGV , PySignalHandler )\n" ;
60 aPyFunc += "print 'PyObjSignal PrevHandler of SIGSEGV :', PrevHandler\n" ;
61 aPyFunc += "print 'PyObjSignal actual handler of SIGSEGV :', signal.getsignal( signal.SIGSEGV )\n" ;
62 // if ( PyRun_SimpleString( (char *) aPyFunc.c_str() ) ) {
63 if ( PyRunSimpleString( (char *) aPyFunc.c_str() ) ) {
64 cdebug << ThreadNo() << " " << Name() << " PyRun_SimpleString ERROR " << endl << aPyFunc << endl ;
65 Automaton()->PyUnLock() ;
68 MyPyObjSignal = MyPyRunMethod ;
69 Automaton()->PyFunction( "PyObjSignal" , MyPyObjSignal ) ;
72 MyPyObjSignal = Automaton()->PyFunction( "PyObjSignal" ) ;
76 if ( Automaton()->PyFunction( "PyObjRef" ) == NULL ) {
78 aPyFunc = "import InitPyRunMethod\n" ;
79 aPyFunc += "import sys\n" ;
80 aPyFunc += "import CORBA\n" ;
81 aPyFunc += "import omniORB\n" ;
82 aPyFunc += "def PyObjRef( IORObjStr ) :\n" ;
83 aPyFunc += " orb = CORBA.ORB_init( sys.argv , CORBA.ORB_ID )\n" ;
84 aPyFunc += " objref = orb.string_to_object( IORObjStr )\n" ;
85 aPyFunc += " return objref\n" ;
86 aPyFunc += "InitPyRunMethod.RunMethod( PyObjRef )\n" ;
87 // if ( PyRun_SimpleString( (char *) aPyFunc.c_str() ) ) {
88 if ( PyRunSimpleString( (char *) aPyFunc.c_str() ) ) {
89 cdebug << ThreadNo() << " " << Name() << " PyRun_SimpleString ERROR " << endl << aPyFunc << endl ;
90 Automaton()->PyUnLock() ;
93 MyPyObjRef = MyPyRunMethod ;
94 Automaton()->PyFunction( "PyObjRef" , MyPyObjRef ) ;
97 MyPyObjRef = Automaton()->PyFunction( "PyObjRef" ) ;
100 if ( Automaton()->PyFunction( "PyObjIor" ) == NULL ) {
102 aPyFunc = "import InitPyRunMethod\n" ;
103 aPyFunc += "import sys\n" ;
104 aPyFunc += "import CORBA\n" ;
105 aPyFunc += "import omniORB\n" ;
106 aPyFunc += "def PyObjIor( ObjRef ) :\n" ;
107 aPyFunc += " orb = CORBA.ORB_init( sys.argv , CORBA.ORB_ID )\n" ;
108 aPyFunc += " objIor = orb.object_to_string( ObjRef )\n" ;
109 aPyFunc += " return objIor\n" ;
110 aPyFunc += "InitPyRunMethod.RunMethod( PyObjIor )\n" ;
111 // if ( PyRun_SimpleString( (char *) aPyFunc.c_str() ) ) {
112 if ( PyRunSimpleString( (char *) aPyFunc.c_str() ) ) {
113 cdebug << ThreadNo() << " " << Name() << " PyRun_SimpleString ERROR " << endl << aPyFunc << endl ;
114 Automaton()->PyUnLock() ;
117 MyPyObjIor = MyPyRunMethod ;
118 Automaton()->PyFunction( "PyObjIor" , MyPyObjIor ) ;
121 MyPyObjIor = Automaton()->PyFunction( "PyObjIor" ) ;
123 Automaton()->PyUnLock() ;
125 cdebug_out << "InitPython" << endl ;
130 PyObject * GraphExecutor::InNode::InitPyDynInvoke( char * PyFuncName ,
131 const SUPERV::ListOfStrings * aPythonFunction ,
136 PyObject * thePyRunMethod = NULL ;
138 cdebug_in << "InitPyDynInvoke '" << PyFuncName << "' length " << (*aPythonFunction).length() << endl ;
140 if ( strlen( PyFuncName ) ) {
141 Automaton()->PyLock() ;
142 thePyRunMethod = Automaton()->PyFunction( PyFuncName ) ;
143 if ( (*aPythonFunction).length() ) {
144 if ( thePyRunMethod == NULL ) {
146 aPyFunc += "import InitPyRunMethod\n" ;
147 for ( i = 0 ; i < (*aPythonFunction).length() ; i++ ) {
148 aPyFunc += (*aPythonFunction)[ i ] ;
151 aPyFunc += "InitPyRunMethod.RunMethod( " ;
152 aPyFunc += PyFuncName ;
154 /*cdebug *///cout<< "InitPyDynInvoke PyRun_SimpleString " << endl << aPyFunc << endl ;
155 // if ( PyRun_SimpleString( (char *) aPyFunc.c_str() ) ) {
156 if ( PyRunSimpleString( (char *) aPyFunc.c_str() ) ) {
157 cdebug << ThreadNo() << " " << Name() << " PyRunSimpleString ERROR " << endl << aPyFunc << endl ;
162 PyFuncRunned( true ) ;
163 thePyRunMethod = MyPyRunMethod ;
165 Automaton()->PyFunction( PyFuncName , thePyRunMethod ) ;
166 cdebug << ThreadNo() << "PyRunSimpleString( " << (*aPythonFunction)[ 0 ] << " ) " << endl ;
170 Automaton()->PyUnLock() ;
171 cdebug_out << "InitPyDynInvoke '" << PyFuncName << "' thePyRunMethod " << thePyRunMethod << " "
172 << thePyRunMethod->ob_refcnt << endl ;
173 return thePyRunMethod ;
176 else if ( thePyRunMethod ) {
177 Automaton()->PyUnLock() ;
178 cdebug_out << "InitPyDynInvoke '" << PyFuncName << "' thePyRunMethod " << thePyRunMethod << " "
179 << thePyRunMethod->ob_refcnt << endl ;
180 return thePyRunMethod ;
182 Automaton()->PyUnLock() ;
185 cdebug_out << "InitPyDynInvoke '" << PyFuncName << "' thePyRunMethod Null" << endl ;
190 extern "C" PyObject * PyRunMethod( PyObject * dummy , PyObject * Args ) {
191 PyObject * Result = NULL ;
192 PyObject * Temp = NULL ;
193 if ( PyArg_ParseTuple( Args , "O:set_callback" , & Temp ) ) {
194 // cout << "PyArg_ParsedTuple" << endl ;
195 if ( !PyCallable_Check( Temp ) ) {
196 // PyErr_SetString( PyExc_TypeError , "PyRunMethod must be callable" ) ;
197 // cout << "PyRunMethod must be callable" << endl ;
201 Py_XDECREF( MyPyRunMethod ) ;
202 MyPyRunMethod = Temp ;
203 Py_INCREF( Py_None ) ;
209 bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod ,
211 ServicesAnyData * inParams , int nInParams ,
212 ServicesAnyData * outParams , int nOutParams ) {
217 int n_in = nInParams ;
218 int n_out = nOutParams ;
221 cdebug_in << ThreadNo() << "GraphExecutor::InNode::PyDynInvoke Node " << Name() << " method " << method
222 << " " << n_in << " InArgs " << n_out << " OutArgs MyPyRunMethod " ;
223 if ( MyPyRunMethod ) {
224 cdebug << MyPyRunMethod << " " << MyPyRunMethod->ob_refcnt << endl ;
227 cdebug << " NULL" << endl ;
233 PyObject * ArgsList = NULL ;
234 PyObject * ArgValue = NULL ;
235 PyObject * Result = NULL ;
236 PyObject * MyPyObjRefList = NULL ;
237 PyObject * ResultObj = NULL ;
238 PyObject * MyPyObjIorList = NULL ;
239 PyObject * ResultIor = NULL ;
241 CORBA::Object_ptr ObjRef ;
244 if ( !PyCallable_Check( MyPyRunMethod ) ) {
249 ArgsList = PyTuple_New( n_in ) ;
251 for ( i = 0 ; i < n_in ; i++ ) {
252 data = inParams[i].Value ;
253 sname = inParams[i].Name.c_str() ;
254 switch ( data.type()->kind() ) {
255 case CORBA::tk_string : {
258 ArgValue = Py_BuildValue( "s" , t ) ;
259 PyTuple_SetItem( ArgsList , i , ArgValue ) ;
260 cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value " << t << " (string) "
261 << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
262 << ArgValue->ob_refcnt << endl ;
265 case CORBA::tk_boolean : {
267 data >>= (CORBA::Any::to_boolean ) b ;
268 ArgValue = Py_BuildValue( "b" , b ) ;
269 PyTuple_SetItem( ArgsList , i , ArgValue ) ;
270 cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value " << b
271 << " (boolean) ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
272 << ArgValue->ob_refcnt << endl ;
275 case CORBA::tk_char : {
277 data >>= (CORBA::Any::to_char ) c ;
278 ArgValue = Py_BuildValue( "c" , c ) ;
279 PyTuple_SetItem( ArgsList , i , ArgValue ) ;
280 cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value " << c
281 << " (char) ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
282 << ArgValue->ob_refcnt << endl ;
285 case CORBA::tk_short : {
288 ArgValue = Py_BuildValue( "h" , s ) ;
289 PyTuple_SetItem( ArgsList , i , ArgValue ) ;
290 cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value " << s
291 << " (short) ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
292 << ArgValue->ob_refcnt << endl ;
295 case CORBA::tk_long : {
298 ArgValue = Py_BuildValue( "l" , l ) ;
299 PyTuple_SetItem( ArgsList , i , ArgValue ) ;
300 cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value " << l
301 << " (long) ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
302 << ArgValue->ob_refcnt << endl ;
305 case CORBA::tk_float : {
308 ArgValue = Py_BuildValue( "f" , f ) ;
309 PyTuple_SetItem( ArgsList , i , ArgValue ) ;
310 cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value " << f
311 << " (float) ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
312 << ArgValue->ob_refcnt << endl ;
315 case CORBA::tk_double : {
318 ArgValue = Py_BuildValue( "d" , d ) ;
319 PyTuple_SetItem( ArgsList , i , ArgValue ) ;
320 cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value " << d
321 << " (double) ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
322 << ArgValue->ob_refcnt << endl ;
325 case CORBA::tk_objref : {
326 MyPyObjRefList = PyTuple_New( 1 ) ;
327 PyObject * ObjValue ;
329 IORObjRef = ObjectToString( ObjRef ) ;
330 ObjValue = Py_BuildValue( "s" , IORObjRef ) ;
331 PyTuple_SetItem( MyPyObjRefList , 0 , ObjValue ) ;
332 cdebug << "ArgIn" << i << " : " << sname << " " << method << " " << " Value " << IORObjRef << " (objref) "
333 << MyPyObjRef->ob_refcnt << "/" << MyPyObjRefList->ob_refcnt << endl ;
334 // ResultObj = PyEval_CallObject( MyPyObjRef , MyPyObjRefList ) ;
335 ResultObj = PyEvalCallObject( MyPyObjRef , MyPyObjRefList ) ;
336 cdebug << "ObjValue->ob_refcnt" << ObjValue->ob_refcnt << endl ;
337 ArgValue = Py_BuildValue( "O" , ResultObj ) ;
338 PyTuple_SetItem( ArgsList , i , ArgValue ) ;
339 cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value (objref) ArgsList->ob_refcnt"
340 << ArgsList->ob_refcnt << " ArgValue->ob_refcnt" << ArgValue->ob_refcnt << endl ;
341 cdebug << "MyPyObjRefList->ob_refcnt " << MyPyObjRefList->ob_refcnt-1 << endl ;
342 Py_DECREF( MyPyObjRefList ) ;
343 if ( CORBA::is_nil( ObjRef ) ) {
347 cdebug << "ResultObj->ob_refcnt " << ResultObj->ob_refcnt-1 << endl ;
348 Py_DECREF( ResultObj ) ;
353 cdebug << "ArgIn" << i << " : " << sname << " Value " << "(other ERROR)" << endl ;
358 // Result = PyEval_CallObject( MyPyRunMethod , ArgsList ) ;
359 Result = PyEvalCallObject( MyPyRunMethod , ArgsList ) ;
361 cdebug << "ArgsList->ob_refcnt" << ArgsList->ob_refcnt << endl ;
363 if ( Result == NULL ) {
364 cdebug_out << "GraphExecutor::InNode::PyDynInvoke Node " << Name() << " " << method << " Error Result == NULL"
369 for ( i = 0 ; i < n_out ; i++ ) {
370 data = outParams[i].Value ;
371 sname = outParams[i].Name.c_str() ;
372 switch ( data.type()->kind() ) {
373 case CORBA::tk_string : {
375 if ( PyTuple_Check( Result ) ) {
376 ArgValue = PyTuple_GetItem( Result , i ) ;
381 if ( !PyString_Check( ArgValue ) ) {
382 cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (string)" << endl ;
385 t = PyString_AsString( ArgValue ) ;
388 cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << t << " (string)"
389 << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
390 << ArgValue->ob_refcnt << endl ;
393 case CORBA::tk_boolean : {
395 if ( PyTuple_Check( Result ) ) {
396 ArgValue = PyTuple_GetItem( Result , i ) ;
401 if ( !PyInt_Check( ArgValue ) ) {
402 cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (boolean)" << endl ;
405 b = PyInt_AsLong( ArgValue ) ;
407 data <<= (CORBA::Any::from_boolean ) b ;
408 cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << b << " (boolean)"
409 << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
410 << ArgValue->ob_refcnt << endl ;
413 case CORBA::tk_char : {
414 unsigned char c = 0 ;
415 if ( PyTuple_Check( Result ) ) {
416 ArgValue = PyTuple_GetItem( Result , i ) ;
421 if ( !PyInt_Check( ArgValue ) ) {
422 cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (char)" << endl ;
425 c = PyInt_AsLong( ArgValue ) ;
427 data <<= (CORBA::Any::from_char ) c ;
428 cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << c << " (char)"
429 << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
430 << ArgValue->ob_refcnt << endl ;
433 case CORBA::tk_short : {
435 if ( PyTuple_Check( Result ) ) {
436 ArgValue = PyTuple_GetItem( Result , i ) ;
441 if ( !PyInt_Check( ArgValue ) ) {
442 cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (short)" << endl ;
445 s = PyInt_AsLong( ArgValue ) ;
448 cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << s << " (short)"
449 << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
450 << ArgValue->ob_refcnt << endl ;
453 case CORBA::tk_long : {
455 if ( PyTuple_Check( Result ) ) {
456 ArgValue = PyTuple_GetItem( Result , i ) ;
461 if ( PyLong_Check( ArgValue ) ) {
462 l = PyLong_AsLong( ArgValue ) ;
464 else if ( PyInt_Check( ArgValue ) ) {
465 l = PyInt_AsLong( ArgValue ) ;
468 cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (CORBA::tk_long)" << endl ;
471 cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << l << " (long)"
472 << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
473 << ArgValue->ob_refcnt << endl ;
476 case CORBA::tk_float : {
478 if ( PyTuple_Check( Result ) ) {
479 ArgValue = PyTuple_GetItem( Result , i ) ;
484 if ( !PyFloat_Check( ArgValue ) ) {
485 cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (float)" << endl ;
488 f = PyFloat_AsDouble( ArgValue ) ;
491 cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << f << " (float)"
492 << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
493 << ArgValue->ob_refcnt << endl ;
496 case CORBA::tk_double : {
498 if ( PyTuple_Check( Result ) ) {
499 ArgValue = PyTuple_GetItem( Result , i ) ;
504 if ( !PyFloat_Check( ArgValue ) ) {
505 cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (double)" << endl ;
508 d = PyFloat_AsDouble( ArgValue ) ;
511 cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << d << " (double)"
512 << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
513 << ArgValue->ob_refcnt << endl ;
516 case CORBA::tk_objref : {
518 MyPyObjIorList = PyTuple_New( 1 ) ;
519 if ( PyTuple_Check( Result ) ) {
520 ObjIor = PyTuple_GetItem( Result , i ) ;
525 cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << "(object reference) "
526 << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ObjIor->ob_refcnt"
527 << ObjIor->ob_refcnt << endl ;
528 Py_INCREF( ObjIor ) ;
529 // PyObject_Print( ObjIor , stdout , 0 ) ;
530 PyTuple_SetItem( MyPyObjIorList , 0 , ObjIor ) ;
531 // ResultIor = PyEval_CallObject( MyPyObjIor , MyPyObjIorList ) ;
532 ResultIor = PyEvalCallObject( MyPyObjIor , MyPyObjIorList ) ;
533 cdebug << "ObjIor->ob_refcnt " << ObjIor->ob_refcnt-1 << endl ;
534 Py_DECREF( ObjIor ) ;
535 cdebug << "MyPyObjIorList->ob_refcnt " << MyPyObjIorList->ob_refcnt-1 << endl ;
536 Py_DECREF( MyPyObjIorList ) ;
537 cdebug << "MyPyObjIor->ob_refcnt " << MyPyObjIor->ob_refcnt << endl ;
540 IOR = PyString_AsString( ResultIor ) ;
541 ObjRef = StringToObject( IOR ) ;
543 IORObjRef = ObjectToString( ObjRef ) ;
544 cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << IORObjRef << " (objref) "
546 if ( CORBA::is_nil( ObjRef ) ) {
550 cdebug << "ResultIor->ob_refcnt " << ResultIor->ob_refcnt-1 << endl ;
551 Py_DECREF( ResultIor ) ;
555 cdebug_out << "GraphExecutor::InNode::PyDynInvoke Error ResultIor == NULL Node "
556 << Name() << " method " << method << " " << endl ;
562 cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << "(other ERROR)" << endl ;
565 outParams[i].Value = data ;
568 cdebug << "Result->ob_refcnt" << Result->ob_refcnt-1 << endl ;
569 Py_DECREF( Result ) ;
572 cdebug << "GraphExecutor::InNode::PyDynInvoke ArgsList->ob_refcnt"
573 << ArgsList->ob_refcnt-1 << endl ;
574 Py_DECREF( ArgsList ) ;
577 cdebug_out << "GraphExecutor::InNode::PyDynInvoke Node " << Name() << " method " << method << " " << RetVal
584 bool GraphExecutor::InNode::PyRunSimpleString( char* thePyString )
586 const bool ErrorValue = true;
589 MESSAGE( pthread_self() << "Python method beginning : " << thePyString );
590 cdebug_in << pthread_self() << "Python method beginning : " << thePyString << endl ;
591 // aRet = PyRun_SimpleString( thePyString );
592 aRet = _OutNode->SuperVisionContainer()->ActivatePythonExecution( thePyString ) ;
593 MESSAGE( pthread_self() << "Python method finished." );
594 cdebug_out << pthread_self() << "Python method finished." << endl ;
596 MESSAGE( pthread_self() << "ERROR: Exception caught running Python method." );
597 cdebug_out << pthread_self() << "ERROR: Exception caught running Python method."
599 MESSAGE( " Python was reinitialized. Previous Python definitions are lost" );
602 // Py_InitModule( "InitPyRunMethod" , MethodPyRunMethod );
603 _OutNode->PyInitialized( false );
609 PyObject * GraphExecutor::InNode::PyEvalCallObject( PyObject * MyPyRunMethod ,
610 PyObject * ArgsList ) {
611 cdebug_in << "Executor::InNode::PyEvalCallObject " << Name() << endl ;
612 PyObject * Result = NULL ;
614 MESSAGE( pthread_self() << "PyEval_CallObject method beginning : " );
615 cdebug << pthread_self() << "PyEval_CallObject method beginning : " << Name() << endl ;
616 // Result = PyEval_CallObject( MyPyRunMethod , ArgsList ) ;
617 Result = _OutNode->SuperVisionContainer()->ActivatePythonExecution( MyPyRunMethod , ArgsList ) ;
618 MESSAGE( pthread_self() << "PyEval_CallObject method finished. Result " << Result );
619 cdebug << pthread_self() << "PyEval_CallObject method finished. Result " << Result << endl ;
620 cdebug_out << "Executor::InNode::PyEvalCallObject " << Name() << endl ;
622 MESSAGE( pthread_self() << "ERROR: Exception caught PyEval_CallObject Python method. Result " << Result );
623 cdebug << pthread_self() << "ERROR: Exception caught PyEval_CallObject Python method. Result "
625 // MESSAGE( " Python was reinitialized. Previous Python definitions are lost Py_IsInitialized " << Py_IsInitialized() );
626 //JR ===> fatal error in python : no current thread
629 // Automaton()->PyInitModule( false ) ;
630 // Py_InitModule( "InitPyRunMethod" , MethodPyRunMethod );
631 // _OutNode->PyInitialized( false );
632 if ( Result == NULL ) {
633 Kill() ; // Reset of _ThreadId
635 cdebug_out << "Executor::InNode::PyEvalCallObject ERROR catched " << Name()
636 << " Py_IsInitialized " << Py_IsInitialized() << endl ;