python and multithreading problem

W

whatazor

Hi all,
I made an application that use multithreading (indifferently importing
thread or threading module) , but when I call some wrapped modules
(with swig) from my application they run like there is only a single
thread (and my application gui ,made with wxPython, freezes). If I use
other modules not wrapped, but created for test that multithread
works, and gui is not freezing are ok.
Modules that wrap DLL are not my product but are created by another
developer with VS.NET, and the only thing I can think is that they're
builded without multithreaded compiler option. Can it be another cause
for this behaviour, can this explanation be correct? maybe also swig
have a multithreading option.

thank you in advance
w
 
D

Diez B. Roggisch

whatazor said:
Hi all,
I made an application that use multithreading (indifferently importing
thread or threading module) , but when I call some wrapped modules
(with swig) from my application they run like there is only a single
thread (and my application gui ,made with wxPython, freezes). If I use
other modules not wrapped, but created for test that multithread
works, and gui is not freezing are ok.
Modules that wrap DLL are not my product but are created by another
developer with VS.NET, and the only thing I can think is that they're
builded without multithreaded compiler option. Can it be another cause
for this behaviour, can this explanation be correct? maybe also swig
have a multithreading option.


There is something called Global Interpreter Lock (GIL) that causes such
behavior. It will ensure that python-code won't interfere with each
other in multiple threads.

However, for C-extensions it is common to release that GIL when a thread
enters the extenison, and grab it again when finished. I don't know if
SWIG does so, but to me it looks as if that is the problem. You might
consider googling swig + gil or something to learn more about it.

Diez
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top