I have a PyQt application that hangs.
Qt 4.7.4 (64-bit)
Python 2.6.1
GCC 4.2.1
OSX 10.6.8
The location of the hang varies. If I disable/rewrite one location of hang, the hang occurs somewhere else shortly afterward.
The application performs searches that might return thousands of custom data objects, each of which might contain fifty child objects.
Logging reveals the hang tends to occur in a loop that creates these custom objects.
ALSO
The application uses threading, however the hang occurs even when I disable these threads. (I am using Laszlo Nagy’s stack trace tool to verify this. The hang occurs even when only the main thread and the stack tracer thread are running.)
The application reads and creates image files. It seems unlikely an I/O lock is the culprit, but I have yet to rule it out.
I WONDER
Is there a limit to the number of python objects I can create?
Is there some other limit I might be reaching?
I’m not doing any explicit object deletion for garbage collection. Should I?
Are there any other usual suspects?
EDIT (8/13):
-
QTimer.singleShot is good to know and a hot lead — however this app doesn’t use singleShot.
-
When the application hangs, it claims 100% CPU (and about 140 MB of memory.)
-
I will try strace ASAP and see what it reveals.
I tried dtruss (rough equivalent of strace on OSX) but didn’t derive much help from the results.
At last I took a coworker’s advice and rolled back my source to its last known non-hanging state. Then I reintroduced changes class by class.
The culprit was a class inheriting from two different QWidget classes, e.g.:
I’m surprised the application worked at all.
Further investigation revealed undoableWidget needed not inherit from QWidget in the first place.
The application no longer hangs, and I am dizzy with relief.
Thank you for the advice. You have helped improve my debugging habits.