[PyQt] Signals across threads is slow

Romain Bignon romain at peerfuse.org
Mon Dec 8 10:22:11 GMT 2008


In a PyQT program, there is two classes, one derived from QThread, and one in
the main GUI thread.

A slot of the GUI thread's class is connected to a QThread signal, and it
seems that this is very slow to emit signal and/or call slot. This result
happens with an empty slot method too.

The hotshot profiler confirms that, the main thread is in the empty slot 70% of
time (and is called only 16 times).

class UDPStreamingThread(QThread):

    def __init__(self):

    def run(self):
        while 1:
            # get some data from socket
            self.emit(SIGNAL('messageReceived'), data)

class UDPStreamingReceiver(QObject):
    def __init__(self, client):

        self.thread = UDPStreamingThread()

        self.connect(self.thread, SIGNAL('messageReceived'), self.messageReceived)

    def messageReceived(self, data):


Romain Bignon -- http://romain.peerfuse.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20081208/84e17b15/attachment.bin

More information about the PyQt mailing list