[PyQt] Disturbing evidence of garbage collection error

Andrew Suffield asuffield at suffields.me.uk
Sun Apr 29 16:21:34 BST 2012


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...)


More information about the PyQt mailing list