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 void | initialize () |
static void | registerGlobalMethod (const char *, PyCFunction, int, const char *, bool=true) |
static void | registerGlobalMethod (const char *, PyCFunctionWithKeywords, int, const char *, bool=true) |
static void | registerGlobalObject (const char *, PyObject *, 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 152 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 168 of file pythonutils.cpp.
|
static |
Execute some python code.
Definition at line 181 of file pythonutils.cpp.
|
static |
Execute a file with Python code.
Definition at line 224 of file pythonutils.cpp.
|
static |
Finalizes the interpreter.
Definition at line 140 of file pythonutils.cpp.
|
inlinestatic |
|
static |
Initializes the interpreter.
Definition at line 68 of file pythonutils.cpp.
|
static |
Register a new method in the main extension module.
Arguments:
Definition at line 248 of file pythonutils.cpp.
|
static |
Register a new method in the main extension module.
Definition at line 304 of file pythonutils.cpp.
|
static |
Add a new object in the main extension module.
Definition at line 311 of file pythonutils.cpp.