Me and a friend are developing an application using Boost :: Python. I defined an interface in C ++ (well, a pure virtual class) that was opened through Boost :: Python for users who need to inherit it and create a class that the application uses and uses for some callback mechanism.
Everything that goes far is good. Now the function callback may take some time (the user can program some heavy things) ... but we need to repaint the window, so it does not look "stuck". We wanted to use Boost :: Thread for this. Only one callback will be executed at a time (no other thread will call python at the same time), so we thought it would not be so much ... since we do not use streams inside python, nor in C ++ code wrapped for python.
What we do is call PyEval_InitThreads () right after Py_Initialize (), then before calling the callback function inside our own boost thread we use the macro PY_BEGIN_ALLOW_THREADS and, and the macro PY_END_ALLOW_THREADS when the thread has ended.
I guess I donβt need to say that execution never reaches the second macro. It shows a few errors every time it starts ... but always when the actual callback is called. I googled a lot, even read some PEP documents on topics, but they all talk about streaming in a python module (which I donβt just consider as a pure virtual class) or streaming in python, and not about the main application that calls Python from multiple threads.
Please help, it upset me a little.
Ps. help!
c ++ python boost-python boost-thread
Fabzter
source share