[PyQt] GUI freezing when running large function in QThread

David Boddie dboddie at trolltech.com
Tue Jul 21 17:55:36 BST 2009


On Tue Jul 21 17:34:38 BST 2009, Brent Villalobos wrote:

> Thanks.  I had a feeling that python's GIL (global interpreter lock)
> would be a limiting factor.  I worked around my performance issue by
> doing some smarting caching to avoid some of the more intensive
> operations.  But for the sake of argument, suppose I couldn't rework my
> algorithms.  From what I can gather, is the common consensus that I need
> to spin off new processes?

It's not obvious from your description of the problem that the GIL is the
main cause, though it may be - it depends what your other module is doing.

When you said this:

> The problem is that my GUI slows way down where actions like mouse clicks
> aren't recognized until the validation function finishes.

it sounds like the behaviour you get when the main thread is being blocked,
as if you were actually performing the verification in the GUI thread. Can
you say how you are accessing the fields in your GUI from the validation
thread?

Alternatively, I could imagine that, on some platforms, things that you do
in the validation thread might affect Qt indirectly. I have vague thoughts
about X11 here, but perhaps I'm just being paranoid. Which platform are
you running on?

David


More information about the PyQt mailing list