From 8c37390dbb15105348ee9ff9c9accc840209cfdf Mon Sep 17 00:00:00 2001 From: asv Date: Thu, 20 Jan 2005 12:51:48 +0000 Subject: [PATCH] Changes were made to make the code compilable with head version of KERNEL. It is compilable and working: execution of InLine nodes works. Control of execution of Inline nodes - does not work (Kill, Suspend, Resume), because it was implemented using signals, that were caught and handled in Container. --- src/GraphExecutor/DataFlowExecutor_InNode.cxx | 23 ++++++++++ .../DataFlowExecutor_OutNode.cxx | 35 ++++++++------ .../DataFlowExecutor_OutNode.hxx | 10 ++-- .../DataFlowExecutor_PyDynInvoke.cxx | 46 +++++++++++-------- 4 files changed, 77 insertions(+), 37 deletions(-) diff --git a/src/GraphExecutor/DataFlowExecutor_InNode.cxx b/src/GraphExecutor/DataFlowExecutor_InNode.cxx index 589b449..4fa3a64 100644 --- a/src/GraphExecutor/DataFlowExecutor_InNode.cxx +++ b/src/GraphExecutor/DataFlowExecutor_InNode.cxx @@ -565,6 +565,12 @@ bool GraphExecutor::InNode::Suspend() { } else { // Now we can suspend an InLineNode with the handler of the SuperVision Container + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + State( GraphExecutor::ErroredState ) ; + _OutNode->State( GraphExecutor::ErroredState ) ; RetVal = false; + cdebug << "Suspend of InLine nodes is NOT implemented." << endl; + MESSAGE( "Suspend of InLine nodes is NOT implemented." ); + /* if ( pthread_kill( _OutNode->MainThreadId() , SIGUSR2 ) == -1 ) { perror("Suspend pthread_kill error") ; State( GraphExecutor::ErroredState ) ; @@ -591,6 +597,7 @@ bool GraphExecutor::InNode::Suspend() { << endl ; } } + */ } } else { @@ -723,6 +730,13 @@ bool GraphExecutor::InNode::Kill() { else { //PAL6886 // Now we can kill an InLineNode with the handler of the SuperVision Container + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + State( GraphExecutor::ErroredState ) ; + _OutNode->State( GraphExecutor::ErroredState ) ; + RetVal = false ; + cdebug << "Kill of InLine nodes is NOT implemented." << endl; + MESSAGE( "Kill of InLine nodes is NOT implemented." ); + /* cdebug << pthread_self() << "Kill of InLineNode " << Name() << " MainThreadId " << _OutNode->MainThreadId() << " :" << endl ; MESSAGE( pthread_self() << "Kill of InLineNode " << Name() << " MainThreadId " @@ -741,6 +755,7 @@ bool GraphExecutor::InNode::Kill() { << " done. MainThreadId " << _OutNode->MainThreadId() ) ; RetVal = true ; } + */ } } else if ( IsSuspended() ) { @@ -939,6 +954,13 @@ bool GraphExecutor::InNode::Resume() { } else { // Resume of InLinePythonNode in the Node of the SuperVisionContainer ... + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + State( GraphExecutor::ErroredState ) ; + _OutNode->State( GraphExecutor::ErroredState ) ; + RetVal = false ; + cdebug << "Resume of InLine nodes is NOT implemented." << endl; + MESSAGE( "Resume of InLine nodes is NOT implemented." ); + /* cdebug << ThreadNo() << "/" << pthread_self() << "Resume of InLineNode pthread_kill" << Name() << endl ; if ( pthread_kill( _OutNode->MainThreadId() , SIGCONT ) == -1 ) { @@ -951,6 +973,7 @@ bool GraphExecutor::InNode::Resume() { State( GraphExecutor::ExecutingState ) ; RetVal = true ; } + */ } } else if ( State() == GraphExecutor::SuspendedSuccessedState ) { diff --git a/src/GraphExecutor/DataFlowExecutor_OutNode.cxx b/src/GraphExecutor/DataFlowExecutor_OutNode.cxx index 2a92e6c..88e0cb3 100644 --- a/src/GraphExecutor/DataFlowExecutor_OutNode.cxx +++ b/src/GraphExecutor/DataFlowExecutor_OutNode.cxx @@ -32,7 +32,8 @@ using namespace std; #include "DataFlowEditor_DataFlow.hxx" -extern Engines_Container_i * _TheContainer ; +// asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL +//extern Engines_Container_i * _TheContainer ; extern GraphExecutor::FiniteStateMachine * theAutomaton ; @@ -43,8 +44,9 @@ extern char ** _ArgV ; GraphExecutor::OutNode::OutNode() { // Graph() { - _SuperVisionContainer = _TheContainer ; - _MainThreadId = SuperVisionContainer()->MainThreadId() ; + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + //_SuperVisionContainer = _TheContainer ; + //_MainThreadId = SuperVisionContainer()->MainThreadId() ; _Valid = false ; _Executable = false ; _Done = false ; @@ -84,8 +86,9 @@ GraphExecutor::OutNode::OutNode( CORBA::ORB_ptr ORB, _prof_debug , _fdebug ) ; _Graph = _StreamGraph ; } - _SuperVisionContainer = _TheContainer ; - _MainThreadId = SuperVisionContainer()->MainThreadId() ; + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + //_SuperVisionContainer = _TheContainer ; + //_MainThreadId = SuperVisionContainer()->MainThreadId() ; _Valid = false ; _Executable = false ; _Done = false ; @@ -148,8 +151,9 @@ GraphExecutor::OutNode::OutNode( CORBA::ORB_ptr ORB, _prof_debug , _fdebug ) ; _Graph = _StreamGraph ; } - _SuperVisionContainer = _TheContainer ; - _MainThreadId = SuperVisionContainer()->MainThreadId() ; + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + //_SuperVisionContainer = _TheContainer ; + //_MainThreadId = SuperVisionContainer()->MainThreadId() ; _Valid = false ; _Executable = false ; _Done = false ; @@ -515,7 +519,9 @@ bool GraphExecutor::OutNode::Run( const bool AndSuspend ) { if ( !Py_IsInitialized() ) { // PyEval_InitThreads() ; // Py_Initialize() ; -// PySys_SetArgv( _ArgC , _ArgV ) ; + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + // 1 line below uncommented + PySys_SetArgv( _ArgC , _ArgV ) ; } anInNode->InitPython() ; PyInitialized( true ) ; @@ -750,13 +756,14 @@ void GraphExecutor::OutNode::CheckAllDone() { << _SuspendedThreads << " EventQSize " << EventQSize() << endl ; } -Engines_Container_i * GraphExecutor::OutNode::SuperVisionContainer() { - return _SuperVisionContainer ; -} +// asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL +//Engines_Container_i * GraphExecutor::OutNode::SuperVisionContainer() { +// return _SuperVisionContainer ; +//} -const pthread_t GraphExecutor::OutNode::MainThreadId() const { - return _MainThreadId ; -} +//const pthread_t GraphExecutor::OutNode::MainThreadId() const { +// return _MainThreadId ; +//} void GraphExecutor::OutNode::PThreadLock( pthread_mutex_t * aMutex , char * errmsg ) { // if ( strcmp( errmsg , "EventLoop" ) && strcmp( errmsg , "EventW" ) ) { diff --git a/src/GraphExecutor/DataFlowExecutor_OutNode.hxx b/src/GraphExecutor/DataFlowExecutor_OutNode.hxx index e44168b..277d93f 100644 --- a/src/GraphExecutor/DataFlowExecutor_OutNode.hxx +++ b/src/GraphExecutor/DataFlowExecutor_OutNode.hxx @@ -54,8 +54,9 @@ namespace GraphExecutor { SUPERV::ControlState _ControlState ; bool _Done ; - Engines_Container_i * _SuperVisionContainer ; - pthread_t _MainThreadId ; + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + //Engines_Container_i * _SuperVisionContainer ; + //pthread_t _MainThreadId ; pthread_mutex_t _PyMutexWait ; pthread_mutex_t _MutexWait ; pthread_cond_t _EventWait ; @@ -150,8 +151,9 @@ namespace GraphExecutor { void CheckAllDone() ; - Engines_Container_i * SuperVisionContainer() ; - const pthread_t MainThreadId() const ; + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + //Engines_Container_i * SuperVisionContainer() ; + //const pthread_t MainThreadId() const ; void PThreadLock( pthread_mutex_t * aMutex , char * errmsg ) ; void PThreadUnLock( pthread_mutex_t * aMutex , char * errmsg ) ; void PyThreadLock() ; diff --git a/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx b/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx index 09baea8..4a553e4 100644 --- a/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx +++ b/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx @@ -35,8 +35,9 @@ bool GraphExecutor::InNode::InitPython() { Automaton()->PyLock() ; // PyObject * Module = Py_InitModule( "InitPyRunMethod" , MethodPyRunMethod ) ; if ( !Automaton()->PyInitModule() ) { -// Py_InitModule( "InitPyRunMethod" , MethodPyRunMethod ) ; - _OutNode->SuperVisionContainer()->ActivatePythonExecution( "InitPyRunMethod" , MethodPyRunMethod ) ; + Py_InitModule( "InitPyRunMethod" , MethodPyRunMethod ) ; + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + //_OutNode->SuperVisionContainer()->ActivatePythonExecution( "InitPyRunMethod" , MethodPyRunMethod ) ; } // PyObject * Dictionnary = PyModule_GetDict( Module ) ; // InitPyDynInvokeError = PyErr_NewException( "InitPyDynInvokeError" , NULL , NULL ) ; @@ -85,8 +86,9 @@ bool GraphExecutor::InNode::InitPython() { aPyFunc += " objref = orb.string_to_object( IORObjStr )\n" ; aPyFunc += " return objref\n" ; aPyFunc += "InitPyRunMethod.RunMethod( PyObjRef )\n" ; -// if ( PyRun_SimpleString( (char *) aPyFunc.c_str() ) ) { - if ( PyRunSimpleString( (char *) aPyFunc.c_str() ) ) { + if ( PyRun_SimpleString( (char *) aPyFunc.c_str() ) ) { + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + //if ( PyRunSimpleString( (char *) aPyFunc.c_str() ) ) { cdebug << ThreadNo() << " " << Name() << " PyRun_SimpleString ERROR " << endl << aPyFunc << endl ; Automaton()->PyUnLock() ; return false ; @@ -110,8 +112,9 @@ bool GraphExecutor::InNode::InitPython() { aPyFunc += " objIor = orb.object_to_string( ObjRef )\n" ; aPyFunc += " return objIor\n" ; aPyFunc += "InitPyRunMethod.RunMethod( PyObjIor )\n" ; -// if ( PyRun_SimpleString( (char *) aPyFunc.c_str() ) ) { - if ( PyRunSimpleString( (char *) aPyFunc.c_str() ) ) { + if ( PyRun_SimpleString( (char *) aPyFunc.c_str() ) ) { + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + //if ( PyRunSimpleString( (char *) aPyFunc.c_str() ) ) { cdebug << ThreadNo() << " " << Name() << " PyRun_SimpleString ERROR " << endl << aPyFunc << endl ; Automaton()->PyUnLock() ; return false ; @@ -602,8 +605,9 @@ bool GraphExecutor::InNode::PyRunSimpleString( char* thePyString ) try { MESSAGE( pthread_self() << "Python method beginning : " << thePyString ); cdebug_in << pthread_self() << "Python method beginning : " << thePyString << endl ; -// aRet = PyRun_SimpleString( thePyString ); - aRet = _OutNode->SuperVisionContainer()->ActivatePythonExecution( thePyString ) ; + aRet = PyRun_SimpleString( thePyString ); + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + //aRet = _OutNode->SuperVisionContainer()->ActivatePythonExecution( thePyString ) ; MESSAGE( pthread_self() << "Python method finished." ); cdebug_out << pthread_self() << "Python method finished." << endl ; } catch( ... ) { @@ -611,9 +615,10 @@ bool GraphExecutor::InNode::PyRunSimpleString( char* thePyString ) cdebug_out << pthread_self() << "ERROR: Exception caught running Python method." << endl ; MESSAGE( " Python was reinitialized. Previous Python definitions are lost" ); -// Py_Finalize(); -// Py_Initialize(); -// Py_InitModule( "InitPyRunMethod" , MethodPyRunMethod ); + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + Py_Finalize(); + Py_Initialize(); + Py_InitModule( "InitPyRunMethod" , MethodPyRunMethod ); _OutNode->PyInitialized( false ); aRet = ErrorValue; } @@ -627,8 +632,9 @@ PyObject * GraphExecutor::InNode::PyEvalCallObject( PyObject * MyPyRunMethod , try { MESSAGE( pthread_self() << "PyEval_CallObject method beginning : " ); cdebug << pthread_self() << "PyEval_CallObject method beginning : " << Name() << endl ; -// Result = PyEval_CallObject( MyPyRunMethod , ArgsList ) ; - Result = _OutNode->SuperVisionContainer()->ActivatePythonExecution( MyPyRunMethod , ArgsList ) ; + Result = PyEval_CallObject( MyPyRunMethod , ArgsList ) ; + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + //Result = _OutNode->SuperVisionContainer()->ActivatePythonExecution( MyPyRunMethod , ArgsList ) ; MESSAGE( pthread_self() << "PyEval_CallObject method finished. Result " << Result ); cdebug << pthread_self() << "PyEval_CallObject method finished. Result " << Result << endl ; cdebug_out << "Executor::InNode::PyEvalCallObject " << Name() << endl ; @@ -636,13 +642,15 @@ PyObject * GraphExecutor::InNode::PyEvalCallObject( PyObject * MyPyRunMethod , MESSAGE( pthread_self() << "ERROR: Exception caught PyEval_CallObject Python method. Result " << Result ); cdebug << pthread_self() << "ERROR: Exception caught PyEval_CallObject Python method. Result " << Result << endl ; -// MESSAGE( " Python was reinitialized. Previous Python definitions are lost Py_IsInitialized " << Py_IsInitialized() ); + MESSAGE( " Python was reinitialized. Previous Python definitions are lost Py_IsInitialized " << Py_IsInitialized() ); //JR ===> fatal error in python : no current thread -// Py_Finalize(); -// Py_Initialize(); -// Automaton()->PyInitModule( false ) ; -// Py_InitModule( "InitPyRunMethod" , MethodPyRunMethod ); -// _OutNode->PyInitialized( false ); + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + Py_Finalize(); + Py_Initialize(); + Automaton()->PyInitModule( false ) ; + Py_InitModule( "InitPyRunMethod" , MethodPyRunMethod ); + _OutNode->PyInitialized( false ); + if ( Result == NULL ) { Kill() ; // Reset of _ThreadId } -- 2.39.2