Mixing Python and C threads

Stéphane Larouche stephane.larouche at polymtl.ca
Fri Jul 6 15:45:32 CEST 2007


I am currently developing a software called OpenFilters (available at
www.polymtl.ca/larfis). Most of the software is written in Python, but the
classes that do the hard work are written in C++ modules. Since, nowadays, most
new computers have multiple cores and that I want to speed up the software, I am
currently trying to add some multithreading to the C++ modules using openmp.

If I call the methods in the C++ modules from the Python main thread, I don't
have any problem. However, they are usually called from another Python thread
(using the threading module) to keep the GUI responsive and, then, Python
crashes.

The C++ multithreaded part does not call any Python function. It crashes whether
it is surrounded by Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS or not. I am
using Python 2.5 on Windows XP. The modules are compiled with gcc 4.2 (MinGW
unofficial release available at
http://www.esnips.com/doc/9dba8ac7-70c7-4f98-a0fa-8ea315267073/gcc-4.2.0mingw-
release-patched-SSE).

Has anybody had a similar problem? Do you know how to solve it?

Thank you for your help,

Stéphane Larouche





More information about the Python-list mailing list