This class is used to maintain the Python interpreter. More...
#include <utils.h>
Static Public Member Functions | |
static void | addThread () |
static void | deleteThread () |
static void | execute (const char *) |
static void | executeFile (string) |
static void | finalize () |
static PyObject * | getModule () |
static const char * | getPythonEncoding () |
static void | initialize (int argc, char **argv) |
static void | registerGlobalMethod (const char *, PyCFunction, int, const char *, bool=true) |
static void | registerGlobalMethod (const char *, PyCFunctionWithKeywords, int, const char *, bool=true) |
This class is used to maintain the Python interpreter.
A single interpreter is used throughout the lifetime of the application.
The implementation is implemented in a thread-safe way (within the limitations of the Python threading model, of course).
During the initialization the code checks for a file 'init.py' in its search path and, if it does exist, the statements in the file will be executed. In this way a library of globally available functions can easily be initialized.
The stderr and stdout streams of Python are redirected by default to the frePPLe log stream.
The following frePPLe functions are available from within Python.
All of these are in the module called frePPLe.
The technical implementation is inspired by and inherited from the following article: "Embedding Python in Multi-Threaded C/C++ Applications", see http://www.linuxjournal.com/article/3641
|
static |
Create a new Python thread state.
Each OS-level thread needs to initialize a Python thread state as well. When a new thread is created in the OS, this method should be called to create a Python thread state as well.
See the Python PyGILState_Ensure API.
Definition at line 154 of file pythonutils.cpp.
|
static |
Delete a Python thread state.
Each OS-level thread has a Python thread state. When an OS thread is deleted, this method should be called to delete the Python thread state as well.
See the Python PyGILState_Release API.
Definition at line 170 of file pythonutils.cpp.
|
static |
Execute some python code.
Definition at line 183 of file pythonutils.cpp.
|
static |
Execute a file with Python code.
Definition at line 223 of file pythonutils.cpp.
|
static |
Finalizes the interpreter.
Definition at line 142 of file pythonutils.cpp.
|
inlinestatic |
|
static |
Return the preferred encoding of the Python interpreter.
Definition at line 46 of file pythonutils.cpp.
|
static |
Initializes the interpreter.
Definition at line 52 of file pythonutils.cpp.
|
static |
Register a new method to Python.
Arguments:
Definition at line 243 of file pythonutils.cpp.
|
static |
Register a new method to Python.
Definition at line 299 of file pythonutils.cpp.