[PyKDE] Multithreaded GUI programming

Michael Lauer mickey at tm.informatik.uni-frankfurt.de
Sat Dec 7 16:36:01 GMT 2002


> The problem is: How not to waste CPU
> > resources by using a timer
> > to poll the communication Queue from within the GUI thread.
> 
> I don't imagine that the polling is going to be particularly expensive but 
> I've never measured it. Have you?

We've done some tests -- not by measuring, but by evaluating the
responsiveness.
Basically, it depends on how frequently you poll. As I've said in
another mail, handling a timerEvent in Python code is inherently _slow_,
because interpreted code is being executed rather than compiled code.
A timer set to - say - hundred milliseconds or less _will_ slow down the
GUI event processing noticably, when handled in Python code. 
However, if the timer is set to, say seconds instead of milliseconds,
the slowdown will be hardly noticable, but the latency, i.e. the time
between the worker thread notifies the GUI and the GUI actually has a
chance to poll the queue and to update the display, will increase.

> Are you not able to use QApplication.lock() and unlock() around the postEvent?

Unfortunately not. lock() and unlock() are only available in
multithreaded Qt.

Yours,
-- 
:M:
--------------------------------------------------------------------------
Dipl.-Inf. Michael 'Mickey' Lauer  
mickey at tm.informatik.uni-frankfurt.de 
  Raum 10b - ++49 69 798 28358       Fachbereich Informatik und Biologie
--------------------------------------------------------------------------




More information about the PyQt mailing list