[PyQt] Signal Bug in 4.2

Giovanni Bajo rasky at develer.com
Tue Jul 24 23:09:10 BST 2007

On mar, 2007-07-24 at 14:54 -0700, Peter Shinners wrote:

> We have just migrated code from using PyQt-4.2 on Qt-4.2 to using 
> PyQt-4.2 on Qt-4.2. This has revealed what looks like a very serious bug 
> in the signal handling code for PyQt-4.2.

You may want to run latest SIP/PyQt snapshots, as there were several
fixes in them that might sort out your issue as well.

> We have Python "value" objects derived from QObject. These emit a value 
> change event to other values and to listening QWidget derived objects. 
> After a short (yet non-repeatable) series of actions, the signal 
> callbacks will no longer be called. We can confirm that the objects on 
> both sides are still valid.

Are those normal signals or shortcircuit signals?

> We are not ruling out a problem on our end yet. Again, this works 
> without error on 4.1.1, but will always fail with 4.2. The thing that 
> makes this tricky is there is no purely repeatable way to trigger the 
> problem. But it always happens within a small number of steps.

Since computers are deterministic, there are only a few sources of non
determinism that might cause erratic/random behaviour:

1) [most obvious) Randomness. If the behaviour of your program depends
on random, fix that with a fixed seed.

2) Python garbage collector. Try disable it altogether (gc.disable() at
startup), or start sticking explicit collection calls (gc.collect()) in
several places in your code. If the behaviour your observe is tied to
collectors invokation, you should start reproducing it more faithfully
with these tricks.

3) Address of objects in memory. That changes at every execution (or
so). In Python, it's usually observable in a few key operations:
  * Order of iteration over dictionaries/sets.
  * id() of instances.

> The layers of code also make this difficult to reduce to a minimal test 
> case. I know that would largely help this get tracked down, but I am 
> coming here to look for solutions early.

Extracting small testcases is always possible (albeit not simple). It'll
take you a few hours, but you'll get there. I suggest you start trying
because there's no way things can get fixed with a vague description of
a problem.

(I'll note that I have heard a similar problem from a fellow developer a
few days ago, but I had forgetten. I'll try to dig up the issue, and
extract a small testcase myself if it is still present).
Giovanni Bajo

More information about the PyQt mailing list