[PyQt] Disturbing evidence of garbage collection error

Hans-Peter Jansen hpj at urpla.net
Mon Apr 30 08:25:52 BST 2012


Dear Andrew,

Am Sunday 29 April 2012 17:21:34 schrieb Andrew Suffield:
> On Sun, Apr 29, 2012 at 03:51:43PM +0100, Phil Thompson wrote:
> > You might try keeping explicit references to any objects involved in the
> > query where you might be expecting PyQt to keep the reference for you.
>
> At the point when it gets collected, it's still in scope as a local
> variable of the python function that's currently executing on that
> thread. This is as horribly wrong as it sounds. I keep thinking it
> should be memory corruption, but valgrind says it's clean.
>
> (After spending most of yesterday trying to figure it out, I gave up
> and rewrote the database code to use multiprocessing instead of
> QThreads. Trying to get them to work has resulted in me spending
> entirely too much time using gdb and valgrind to find bugs in python
> and Qt; it's not worth the trouble when neither of them are very
> reliable in the presence of threads. If only QtSql was asynchronous
> like everything else...)

following Eriks suggestion of disabling the GC altogether would have given a 
valuable data point for your issue. Vanishing still referenced local 
variables in a thread context is more than a disturbing evidence, that 
deserves some deep examination. 

Pete


More information about the PyQt mailing list