[PyQt] GUI freezing when running large function in QThread

Matt Newell newellm at blur.com
Wed Jul 22 23:46:03 BST 2009


On Wednesday 22 July 2009 14:12:11 Brent Villalobos wrote:
> Erik Janssens wrote:
> > If you interface to C code within your validation, does the interface
> > release the GIL ?
>
> Unfortunately I'm not much of a C person.  How do I check if the GIL has
> been released?


sip/PyQt is very aggressive when it comes to releasing the GIL.  Therefore if 
you are calling a lot of qt functions in your threads, it should be giving 
plenty of opportunities for other threads to run.  Especially if your threads 
are doing blocking operations where the GIL is released for longish periods 
of time.

If you are doing lots of python only processing in your threads that probably 
will cause the threads to hog the GIL and not allow others to run.  There are 
some options to allow other threads to run either at certain intervals or 
manually by calling time.sleep.  I'm not experienced with these techniques 
but a quick google search brings up some articles and discussions.
http://www.pyzine.com/Issue001/Section_Articles/article_ThreadingGlobalInterpreter.html

Matt


More information about the PyQt mailing list