[Twisted-Python] cleanup in twisted

Joachim Boomberschloss boomberschloss at yahoo.com
Mon May 23 08:12:49 EDT 2005


--- Jp Calderone <exarkun at divmod.com> wrote:
> On Mon, 23 May 2005 02:40:53 -0700 (PDT), Joachim
> Boomberschloss <boomberschloss at yahoo.com> wrote:
> >
> >--- Bob Ippolito <bob at redivi.com> wrote:
> >>
> >> On May 22, 2005, at 8:46 AM, Joachim
> Boomberschloss
> >> wrote:
> >>
> >> > I just jotted down a little mechanism for
> >> cleaning-up
> >> > in Twisted, and I wanted to see if:
> >> > 1. other people think it's needed
> >> > 2. other people manage to use it
> >> >
> >> > What this does is enable one to define a
> >> __cleanup__
> >> > method which gets call either when the instance
> is
> >> > deleted, or when the reactor shuts down. It can
> >> return
> >> > a dereffed that delays the shutdown. The
> benefit
> >> is
> >> > being able to define communication-related
> stuff
> >> in
> >> > the cleanup method, which is not so useful to
> do
> >> in
> >> > __del__.
> >>
> >> This is just begging for object leaks, because
> >> __del__ disables
> >> aspects of cyclic GC.
> >
> >Hmmpf. What does this mean, and is there a simple
> way
> >of resolving it?
> >
> 
>   If you construct a reference cycle which contains
> an object which has a __del__ method, the entire
> cycle becomes "garbage" - Python cannot free any of
> the objects or call any of their __del__ methods. 
> Instead, it puts them into the gc module's `garbage'
> list and leaves them there forever.
> 
>   There's no simple way to resolve this (except to
> not implement __del__, of course ;).
> 
>   A non-simple way to resolve it is to use weakref
> callbacks instead of __del__.  Weakref callbacks
> have some nasty bugs in versions of Python older
> than 2.3.5 (more, the further back you go), and
> they're trickier to use than __del__.  They don't
> create garbage cycles, though.
> 

Can you point me to an example of this (preferably in
Twisted)? Is this whole cleanup thing worth my time
fixing it in your opinion?

Joe.


		
Yahoo! Mail
Stay connected, organized, and protected. Take the tour:
http://tour.mail.yahoo.com/mailtour.html





More information about the Twisted-Python mailing list