Heap problems in Mulithreaded Python extension

  • Thread starter Alexander Eisenhuth
  • Start date
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
 
A

Alexander Eisenhuth

ok, once more my "scheme"


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);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top