Re: [Twisted-Python] cleanup in twisted

--- Jp Calderone <exarkun@divmod.com> wrote:
Got it. Well, indeed, this is not exactly what I need because of the limitation you mentioned, but I think I found a solution: to have a global object that points to all instances of Cleanuppable, and a LoopingCall that checks every minute or so whether this global object is the only referrer to each Cleanuppable instance, in which case it activates the __cleanup__ method of the Cleanuppable, and waits for the procedure to complete, then deletes the instance. This is somewhat unelegant (because of the arbitrariness of the LoopingCall as opposed to being dependent on the garbage collection process), but I think it should be completely satisfactory functionality-wise. This brings me back to the question of attractiveness, which makes me suspect that I am missing some point. What I thought was that it would be very convenient to be able to specify once, using a simple Twisted-style idiom, what should happen with an object when it is no longer needed, which, because of the way Twisted works, should be given a chance to execute before the reactor shuts down, but similarly when the object simply dies out normally (i.e. the point here is being able to use deferred to specify a non-instantaneous cleanup procedure). An example of this would be an object that interacts with a remote server that should notify the server before retiring from the interaction. I think the method I proposed including the missing element I described above handles this nicely. I'm not sure what you meant by explicit cleanup. Joe. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
participants (1)
-
Joachim Boomberschloss