By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,201 Members | 914 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,201 IT Pros & Developers. It's quick & easy.

Heap problems in Mulithreaded Python extension

P: n/a
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
Feb 1 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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);
Feb 1 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.