[PyQt] QRunnable issue

Hans-Peter Jansen hpj at urpla.net
Fri Jul 22 20:39:21 BST 2011


On Monday 18 July 2011, 20:36:53 Jeremy Sanders wrote:
> Hi - I'm having problems with the following code where a QRunnable
> emits a signal then ends. If you click the button it should print
> 1,2,3. It sometimes works for the first few times but the wrong
> number of arguments is given to the slot after that.
>
> Is this a PyQt bug? 

I can confirm, that there are issues with your code. At least as long as 
you use old style signals and slots.

If you're interested in how this _could_ look nowadays, see attached 
script runnable2.py. While at it, I pimped up the code a bit in order 
to exercise the signal and slot mechanics a bit harder. It not only 
looks smarter, it delivers a million signals per push without a hitch, 
if you call it like this: python runnable2.py 1000

Compare this with running: python runnable2-old.py 
This should deliver 100 signals, but most of the time, PyQt misses to 
deliver the arguments for the signals at all. It might take a few 
pushes and some scrolling back to see some of them.

> I'm using 4.8.3 on Ubuntu (x86). I've tried 
> setting autodelete on the runnable to be false but that causes a
> crash.

Well, you missed to tell us about the versions you use, and I'm too lazy 
to look them up now.. Anyway, I think, that there are some races in the 
old style signal and slot argument handling code. 

Looks like Phils call..

Cheers,
Pete

python: 2.6.2
sip: 4.12.3
qt4: 4.7.1
pyqt4: 4.8.4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: runnable2.py
Type: application/x-python
Size: 1554 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110722/70ca802b/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: runnable2-old.py
Type: application/x-python
Size: 1507 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110722/70ca802b/attachment-0001.bin>


More information about the PyQt mailing list