A
Alexander Eisenhuth
Hi,
I'm near the ground and need help.
I'm building a multithreaded extension with boost.python.
python extension
-----------------------------------------------------
import extension
extension.init() -> PyEval_InitThreads();
setup 3 threads (pthreads) and do a lot of things, but no python api calls
while true:
time.sleep(0.1)
PyGILState_STATE gGILState;
gGILState = PyGILState_Ensure();
(...) // Do python API calls
PyGILState_Release(gGILState);
So my questions:
- Is it enough to do the following in the extension,
regardless wich thread it does ?
PyGILState_STATE gGILState;
gGILState = PyGILState_Ensure();
(...) // Do python API calls
PyGILState_Release(gGILState);
What happens is, that inside the extension (C++) from time to time
_CrtIsValidHeapPointer(...) fails.
Any comments/experience on "python and threaded extensions" is very welcome.
Alexander
I'm near the ground and need help.
I'm building a multithreaded extension with boost.python.
python extension
-----------------------------------------------------
import extension
extension.init() -> PyEval_InitThreads();
setup 3 threads (pthreads) and do a lot of things, but no python api calls
while true:
time.sleep(0.1)
PyGILState_STATE gGILState;
gGILState = PyGILState_Ensure();
(...) // Do python API calls
PyGILState_Release(gGILState);
So my questions:
- Is it enough to do the following in the extension,
regardless wich thread it does ?
PyGILState_STATE gGILState;
gGILState = PyGILState_Ensure();
(...) // Do python API calls
PyGILState_Release(gGILState);
What happens is, that inside the extension (C++) from time to time
_CrtIsValidHeapPointer(...) fails.
Any comments/experience on "python and threaded extensions" is very welcome.
Alexander