( , /), Python, , , - Python GIL ( ).
non-Python my_cpp_object.non_terminating_fn() , GIL , , - .
time.sleep(1) , , my_cpp_object.non_terminating_fn(), , GIL .
boost::python , , , C/++, GIL, .
( ) ( boost:: python)
class scoped_gil_release {
public:
inline scoped_gil_release() {
m_thread_state = PyEval_SaveThread();
}
inline ~scoped_gil_release() {
PyEval_RestoreThread(m_thread_state);
m_thread_state = NULL;
}
private:
PyThreadState * m_thread_state;
};
int non_terminating_fn_wrapper() {
scoped_gil_release scoped;
return non_terminating_fn();
}