[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

python and multithreading problem

whatazor

1/26/2008 12:13:00 AM

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
1 Answer

Diez B. Roggisch

1/26/2008 7:31:00 AM

0

whatazor schrieb:
> 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