Diez B. Roggisch
1/26/2008 7:31:00 AM
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