[Twisted-web] Custom __del__ not run
rasjidw at openminddev.net
Tue Jul 26 03:49:27 MDT 2005
I have my xmlrpc class that I am running in twisted. I want it to do some
cleaning up when it is finished, and so I have defined a custom __del__
However, when mixed with a looping call, it never gets called. Sample code
below. Remove the two lines starting with self.looping, and it all works as
expected. Put them in, and the custom __del__ is not called.
Is this a bug in twisted? Or have I broken some twisted rule about using
__del__ procedures? Is there some other way of saying 'when you have stopped
the reactor, do foo', that twisted would be happy with?
Any suggestions welcome. :-)
from twisted.web import xmlrpc
from twisted.internet import reactor, task
print 'Init class Hello'
# the following two lines cause the custom __del__
# function to never be called
self.looping = task.LoopingCall(self.foo)
print 'Tidy up class Hello'
"""Return 'hello, world'."""
return 'hello, world!'
return 'Shutting down server'
from twisted.web import server
r = Hello()
reactor.listenTCP(7080, server.Site(r), interface = '127.0.0.1')
if __name__ == '__main__':
Melbourne, Australia (UTC +10 hrs)
More information about the Twisted-web