#include <PythonReactor.hpp>
Inherits pion::platform::Reactor.
Definition at line 42 of file PythonReactor.hpp.
Public Member Functions | |
| PythonReactor (void) | |
| constructs a new PythonReactorReactor object | |
| virtual | ~PythonReactor () |
| virtual destructor: this class is meant to be extended | |
| virtual void | setConfig (const pion::platform::Vocabulary &v, const xmlNodePtr config_ptr) |
| virtual void | updateVocabulary (const pion::platform::Vocabulary &v) |
| virtual void | process (const pion::platform::EventPtr &e) |
| virtual void | query (std::ostream &out, const QueryBranches &branches, const QueryParams &qp) |
| virtual void | start (void) |
| called by the ReactorEngine to start Event processing | |
| virtual void | stop (void) |
| called by the ReactorEngine to stop Event processing | |
| bool | deliverToConnections (PyObject *event_ptr) |
| PyObject * | getSession (PyObject *event_ptr) |
| void | setLogger (PionLogger log_ptr) |
| sets the logger to be used | |
| PionLogger | getLogger (void) |
| returns the logger currently in use | |
| const pion::platform::Vocabulary & | getVocabulary (void) const |
| returns a reference to the universal vocabulary (use carefully!) | |
Static Public Member Functions | |
| static boost::uint64_t | boost_msec_to_fsec (boost::uint64_t n) |
| convert microseconds into boost fractional seconds | |
| static boost::uint64_t | boost_fsec_to_msec (boost::uint64_t n) |
| convert boost fractional seconds into microseconds | |
Protected Member Functions | |
| void | updateTerms (const pion::platform::Vocabulary &v) |
| std::size_t | getNumSessions (void) const |
| returns the number of session objects being tracked | |
| void | flushSessions (void) |
| flushes all sessions that are cached | |
| PyObject * | findPythonFunction (PyObject *module_ptr, const std::string &func_name) |
| void | resetPythonSymbols (void) |
| releases and resets all Python byte code symbols held by the Reactor | |
| void | compilePythonSource (void) |
| compiles the Python source code into executable byte code and initializes the module | |
| void | initPythonModule (void) |
| initialize the Python module using the compiled byte code | |
| void | callPythonStart (void) |
| calls the user-defined Python start() function | |
| void | callPythonStop (void) |
| calls the user-defined Python stop() function | |
| std::string | getSourceCodeFromFile (void) |
| reads the Python source code from the file pointed to by m_source_file | |
| std::string | getPythonError (void) |
| if the Python error indicator is set, clear it and return a corresponding message | |
Static Protected Member Functions | |
| static PyThreadState * | initThreadState (void) |
| static void | releaseThreadState (PyThreadState *ptr) |
Classes | |
| class | EventConversionException |
| exception thrown if there is an error converting between Pion and Python events More... | |
| class | FailedToCompileException |
| exception thrown if the source code fails to compile More... | |
| class | InitReactorObjectException |
| exception thrown if there is an error initialize the Reactor Python class object More... | |
| class | InternalPythonException |
| exception thrown if there is an internal error encountered with the Python API More... | |
| class | NotCallableException |
| exception thrown if a Python source function is defined but it is not callable More... | |
| class | PythonLock |
| simple object used to manage the Python GIL lock & thread-safety More... | |
| class | ReadSourceFileException |
| exception thrown if the source code file cannot be read More... | |
| class | SourceFileNotFoundException |
| exception thrown if the source code file configured is not found More... | |
| class | UnknownTermException |
| exception thrown if unable to find a Vocabulary Term More... | |
| bool pion::plugins::PythonReactor::deliverToConnections | ( | PyObject * | event_ptr | ) |
delivers a Python event to the reactor's connections (used by Python callbacks)
| event_ptr | pointer to a PythonEventObject |
Definition at line 1513 of file PythonReactor.cpp.
References pion::platform::Reactor::deliverEvent(), pion::plugins::PythonEventObject::event_ptr, getPythonError(), and pion::plugins::PythonEventObject::is_unique.
| PyObject * pion::plugins::PythonReactor::findPythonFunction | ( | PyObject * | module_ptr, | |
| const std::string & | func_name | |||
| ) | [protected] |
finds a python function within the compiled byte code for a module
| module_ptr | pointer to the compiled byte code for the module | |
| func_name | name of the Python function to find |
Definition at line 1632 of file PythonReactor.cpp.
Referenced by initPythonModule().
| PyObject * pion::plugins::PythonReactor::getSession | ( | PyObject * | event_ptr | ) |
get a python object associated with the session (creates new one if necessary)
| event_ptr | pointer to a PythonEventObject |
Definition at line 1552 of file PythonReactor.cpp.
References pion::plugins::PythonEventObject::event_ptr, pion::platform::EventPtr::get(), and pion::platform::BasicEvent< CharType, AllocType >::getPointer().
| PyThreadState * pion::plugins::PythonReactor::initThreadState | ( | void | ) | [static, protected] |
initialize the Python state for the current thread, if not done already
Definition at line 1614 of file PythonReactor.cpp.
Referenced by pion::plugins::PythonReactor::PythonLock::PythonLock(), and ~PythonReactor().
| void pion::plugins::PythonReactor::process | ( | const pion::platform::EventPtr & | e | ) | [virtual] |
Processes an Event using a Python function.
| e | pointer to the Event to process |
Reimplemented from pion::platform::Reactor.
Definition at line 1431 of file PythonReactor.cpp.
References pion::platform::Reactor::deliverEvent(), pion::platform::PlatformPlugin::getId(), and getPythonError().
| void pion::plugins::PythonReactor::query | ( | std::ostream & | out, | |
| const QueryBranches & | branches, | |||
| const QueryParams & | qp | |||
| ) | [virtual] |
handle an HTTP query (from QueryService)
| out | the ostream to write the statistics info into | |
| branches | URI stem path branches for the HTTP request | |
| qp | query parameters or pairs passed in the HTTP request |
Definition at line 1498 of file PythonReactor.cpp.
References getNumSessions(), pion::platform::Reactor::writeBeginReactorXML(), pion::platform::Reactor::writeEndReactorXML(), and pion::platform::Reactor::writeStatsOnlyXML().
| void pion::plugins::PythonReactor::releaseThreadState | ( | PyThreadState * | ptr | ) | [static, protected] |
callback function used to release Python state for each thread when it exits
| ptr | pointer to the Python thread state to be released |
Definition at line 1626 of file PythonReactor.cpp.
Referenced by PythonReactor().
| void pion::plugins::PythonReactor::setConfig | ( | const pion::platform::Vocabulary & | v, | |
| const xmlNodePtr | config_ptr | |||
| ) | [virtual] |
sets configuration parameters for this Reactor
| v | the Vocabulary that this Reactor will use to describe Terms | |
| config_ptr | pointer to a list of XML nodes containing Reactor configuration parameters |
Reimplemented from pion::platform::Reactor.
Definition at line 1314 of file PythonReactor.cpp.
References callPythonStart(), callPythonStop(), compilePythonSource(), pion::platform::Reactor::ConfigWriteLock, getPythonError(), getSourceCodeFromFile(), initPythonModule(), pion::platform::Reactor::isRunning(), and updateTerms().
| void pion::plugins::PythonReactor::updateTerms | ( | const pion::platform::Vocabulary & | v | ) | [protected] |
this updates Vocabulary Term references cached for performance
| v | the Vocabulary that this Reactor will use to describe Terms |
Definition at line 1367 of file PythonReactor.cpp.
References pion::platform::Vocabulary::findTerm().
Referenced by setConfig(), and updateVocabulary().
| void pion::plugins::PythonReactor::updateVocabulary | ( | const pion::platform::Vocabulary & | v | ) | [virtual] |
this updates the Vocabulary information used by this Reactor; it should be called whenever the global Vocabulary is updated
| v | the Vocabulary that this Reactor will use to describe Terms |
Reimplemented from pion::platform::Reactor.
Definition at line 1359 of file PythonReactor.cpp.
References pion::platform::Reactor::ConfigWriteLock, and updateTerms().
1.4.7