[PyQt] Garbage collection, signals to partial functions

Andreas Pakulat apaku at gmx.de
Tue Nov 17 17:36:43 GMT 2009


On 17.11.09 18:13:39, Martin Teichmann wrote:
> Hi again, list,
> 
> as per Phil, I changed the code to be executed
> in an event loop. The problem persists.

If I see things correctly, you misunderstood Phil. You're supposed to do
the check in a timer-called-function, not the initialization. That is all
this code:
 
>         # but they're still here!
>         # (following line prints four objects, but should print four Nones)
>         print wa(), wb(), wp(), wf()
> 
>         # OK, let's garbage collect
>         gc.collect()
> 
>         # still everything there (again, not a single None)
>         print wa(), wb(), wp(), wf()
> 
>         # that's the bug: still one reference, but no referrer
>         # (the line prints 1 [], getrefcount always gives 1 to high)
>         if wp() is not None:
>             print sys.getrefcount(wp()) - 1, gc.get_referrers(wp())
> 
>         # assert that everything is gone
>         assert wa() is None
>         assert wb() is None
>         assert wp() is None
>         assert wf() is None

Should be in a slot connected to a timer.

Andreas

-- 
You are fairminded, just and loving.


More information about the PyQt mailing list