David C. Morrill | 18 Jul 17:07

Re: Does a sync_trait connection prevent an object from being garbage collected?

Alexander Michael wrote:
> If after setting up a sync_trait pair one side of the sync (the one
> past in the argument to the sync_trait method) leaves scope with
> nothing referencing it other than the sync_trait event handling (or
> even gets explicitly deleted with the del operator) does the object
> get garbage collected and the sync_trait connection removed? Or does
> the sync_trait setup keep it dangling until I explicitly remove the
> sync'ing with another call to sync_trait with remove=True?
>
> I'm trying to figure out how explicit I need to be about setting up
> and tearing down some wiring in my app in response to user
> interactions that essentially reconfigure the object relationships.
>
> Thanks,
> Alex
>
> _______________________________________________
> Enthought-dev mailing list
> Enthought-dev@...
> https://mail.enthought.com/mailman/listinfo/enthought-dev
>
>   

By design, traits listeners (and sync_traits, which sets up some 
listeners) do not keep either party alive. You will have to save 
explicit references to objects if you want them to not be GC'ed...

Dave Morrill

Gmane