Go to the documentation of this file.
22 #ifndef PYTHON_INTERPRETER_STATE_H
23 #define PYTHON_INTERPRETER_STATE_H
27 #include <boost/python.hpp>
88 PyThreadState *_state =
nullptr;
132 PyGILState_STATE *_state;
135 #endif // PYTHON_INTERPRETER_STATE_H
Manages the Pyton GIL. Useful for threads.
Definition: python_interpreter_state.h:94
Initializes the python interpreter as well as python threading.
Definition: python_interpreter_state.h:33
void allowThreads()
Allow execution of other threads. If this is set, main thread may not execute python code.
Definition: python_interpreter_state.cpp:85
Converts and stores an char*[] to wchar*[]. Used mainly to convert argv from char*[] to wchar*[] for ...
Definition: wchar_t_converter.h:32
static bool hasGIL()
Does this thread have the GIL?
~PythonInterpreterState()
Destructor. Reestablishes thread state.
Definition: python_interpreter_state.cpp:105
PythonGILLock(PyGILState_STATE &state, const bool acquire=true)
Constructor. Acquires GIL if requested.
Definition: python_interpreter_state.cpp:110
~PythonGILLock()
Releases GIL if previously acquired.
Definition: python_interpreter_state.cpp:117
void acquire()
Acquire GIL.
Definition: python_interpreter_state.cpp:123
PythonInterpreterState(int argc, const char *const *argv, bool allowThreads=false)
Constructor. Initializes Python with the given start parameters, enables threading,...
Definition: python_interpreter_state.cpp:48
bool threadsAllowed() const
Are threads currently allowed?
Definition: python_interpreter_state.cpp:91
PythonGILLock & operator=(const PythonGILLock &)=delete
void release()
Release GIL.
Definition: python_interpreter_state.cpp:128
void endAllowThreads()
Halt other threads from executin. This is required if python code should be executed in the main thre...
Definition: python_interpreter_state.cpp:96