[PyQt] Qt.Queuedconnection queue size
Phil Thompson
phil at riverbankcomputing.co.uk
Thu Oct 11 10:25:21 BST 2007
On Thursday 11 October 2007, Dirk Wagener wrote:
> Hi
>
> I have a signal that is emitted from one thread to another. I wire it as
> follows:
>
> QtCore.QObject.connect( self.__model, QtCore.SIGNAL("TestSignal"),
> self.callable1,
> QtCore.Qt.QueuedConnection )
>
> * How do I limit the size of the queue used for the queuedconnection in
> this case?
>
> * When the signal is emitted by one thread, an image is passed to the
> slot. When the slot does not service the signals
> quick enough, the memory usage starts climbing because of the queue just
> growing and growing.
>
> * Is it possible to set the queue size for just one specific signal to
> slot connection?
No - the "queue" is the event queue used by the event loop.
You need something like an image cache (protected my mutexes). Place the image
in the cache and pass the index (or hash or whatever value you use as the
reference of the image in the cache) to the slot. If the cache is too big,
discard old images. When the slot fires it looks for the image and does
nothing if it is no longer in the cache.
Note that there is no need to specify a queued connected. All connections
across threads are queued.
Phil
More information about the PyQt
mailing list