[pygtk] PyGTK object escapes garbage collection
Hrvoje Niksic
hrvoje.niksic at avl.com
Fri Dec 24 18:28:31 WST 2010
The problem you describe sounds like it might be related to this
infamous PyGTK bug:
https://bugzilla.gnome.org/show_bug.cgi?id=546802
In our tests the problems show up when a Python object that participates
in a cycle is referenced only through a GTK widget. When GC takes
place, Python's cycle-breaker incorrectly concludes that the whole cycle
is unreachable and runs tp_clear on all objects. The objects are, of
course, still reachable through PyGTK, and unfortunately now quite broken.
A number of workarounds are available: simply access the widget's
__dict__, which forces it to switch to a different reference-counting
strategy. Or store a reference to your object in a global variable or
container.
More information about the pygtk
mailing list