[Twisted-Python] cleanup in twisted
Jp Calderone
exarkun at divmod.com
Sun May 22 10:25:56 MDT 2005
On Sun, 22 May 2005 09:10:33 -0700, 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.
>
>From the posted code:
class Cleanuppable:
""" Inherit from this if you want to do your cleanup before
Twisted shuts down and not (only) when you get deleted.
If you inherit from this do not implement __del__, only
__cleanup__!
"""
Jp
More information about the Twisted-Python
mailing list