[PyQt] Advice for thread/process output logging, Windows debugging

Steve Borho steve at borho.org
Tue Sep 21 01:00:46 BST 2010


On Thu, Sep 16, 2010 at 3:15 PM, Erik Janssens
<Erik.Janssens at conceptive.be> wrote:
>
> Hello Steve,
>
> We've ran in more or less the same issues with the recent
> refactoring of Camelot, here are some things I learned
> (but I haven't found a decent solution yet) :
>
> - those kind of bugs tend to appear more frequent on windows
>  than on Linux, I don't know why.  But they happen on Linux
>  as well.  The best way to discover them is build stress tests
>  and run the garbage collector explicitly in your test
>
> - try to reproduce them with stress tests on Linux, since
>  debugging on Linux with gdb is much easier
>
> - you can as well disable the garbage collector to see if it
>  prevents the crashes, it usually does
>
> - those crashes are related to ownership problems, see the in
>  depth explanation of Phil :
>
> http://www.riverbankcomputing.com/pipermail/pyqt/2010-September/027705.html
>
> - there are issues when exceptions have been raised in python,
>  since this keeps a stack trace alive with potential references
>  to objects
>
> - some typical pythonic constructions should be avoided inside
>  methods of Qt objects, like closures involving other Qt objects
>  or construction of inner classes, they create difficult to track
>  references
>
> If you learn more on this subject, I'd be very interested.

I was unable to force the crash to occur on other platforms by adding
gc.collect() statements in as many places as I thought might be
"interesting".  It remains a Windows only crash, and after some recent
cleanups of the threading code, it has become harder to reproduce at
all, except on one slow machine of mine.

Another developer submitted this patch (which connects our QDialog
derived dialog's finished signal to it's deleteLater slot):

http://bitbucket.org/tortoisehg/thg/changeset/f71b8c174e9f

And it does indeed appear to make the crash un-reproducable.. I did 20
updates back-to-back without any hitches.

Which begs the question:  What is the "canonical" way to handle modal
dialogs with PyQt4 today?  Should we do explicit cleanup like this?

-- 
Steve Borho


More information about the PyQt mailing list