PDA

View Full Version : Qt event queue overloading?



gct
17th March 2008, 16:22
OK so I'm writing a program in PyQT (Qt3.3), and I've got a stickler of a problem. I'll try to be brief: basically I have a thread that programs some hardware over a range of values (just a sweep type of thing), and at each value, I collect some information, and pass it back to the main event thread for handling.

The handling is a little involved, requires querying a backend over a socket, searching an internal dictionary or two for matching results, updating an on screen table and possible updating the display in a little modal dialog. There aren't any heavy duty calculations going on.

Originally, I was polling the hardware up to 16x/second and sending each response through a custom event to the main gui for handling. This was breaking things (described below), so I switched to dumping the responses into a list (wrapped in a mutex), and then sending a single event if there was anything the GUI needed to handle (instead of getting the data from the event, the GUI now gets it by popping results off the list).

At any rate, both these techniques result in one thing: my event queue dies. There's no exceptions/errors/segfaults or anything, it simply stops processing. I can see that the scanning thread is still active (it still prints out and everything), but the main gui is just dead, no repaint or anything. I even put a QTimer with a zero timeout in that just prints "Event queue is idle!" and sure enough, it stops printing, confirming that the event queue is dead.

So my question is, has anyone seen this kind of behavior? Is it possible to destroy the event queue by having too complex of an event handler? This is a real stumper for me, especially since the data being sent back to the main GUI on each event is < 64 bytes.

wysota
17th March 2008, 16:47
So my question is, has anyone seen this kind of behavior? Is it possible to destroy the event queue by having too complex of an event handler?

No, not really. I think you are facing one of two issues... either you have code that locks itself in your custom event handler causing the whole processing to stop or events are arriving into the queue at a much higher rate than they are processed causing the event handling mechanism to choke. I see no other possibility... unless there's some Python or PyQt issue involved.

gct
17th March 2008, 18:31
That's what I thought to, but I don't have any shared objects in my event handler, so I have no mutexes that could be getting locked causing it to stall...

wysota
17th March 2008, 18:39
Maybe some infinite loop?