12 #include <pybind11/pybind11.h>
21 pCurrentState = PyThreadState_New(interpState);
22 PyEval_AcquireThread(pCurrentState);
27 PyThreadState_Clear(pCurrentState);
28 PyEval_ReleaseThread(pCurrentState);
30 PyThreadState_Delete(pCurrentState);
34 PyThreadState *pCurrentState{
nullptr};
43 PyEval_RestoreThread(
state);
54 void raise()
const override
59 QException *
clone()
const override
64 const char *
what() const noexcept
override
79 call_fn(PyThreadState *main_state, py::object callable, py::args args, py::kwargs kwargs)
84 return callable(*args, **kwargs);
86 catch (
const std::exception &e)
py::object call_fn(PyThreadState *main_state, py::object callable, py::args args, py::kwargs kwargs)
virtual ~PyThreadStateGuard()
PyThreadStateGuard(PyInterpreterState *interpState)
std::exception error() const
const char * what() const noexcept override
QException * clone() const override
ThreadException(const std::exception &err)
virtual ~PyThreadStateReleaser()