[Twisted-Python] Deferred question

Gabriel Rossetti gabriel.rossetti at arimaz.com
Mon Dec 8 04:27:41 EST 2008

Hello everyone,

I have a question concerning defers, I have a service that needs to 
query IO until it answers. The IO can be disconnected, connected but 
off, connected and on; depending on the state I get different 
exceptions. I wrote something like :

def __requestId(self, _):
        d = self.callPlugin(PLUGIN_NAME)

The plugin makes the request in a thread and the deferred is returned 
and called when either an answer is received or am exception is raised 
(e.g. timeout, missing hardware, etc)

This seams to work well, except that when I let the system run for a 
long time without the hardware being present or off (several hours/days) 
the memory consumption goes way up. I don' t really know what is causing 
this, and I'm looking for possible reasons, so I was wondering if maybe 
this could be what is causing the problem. It's probably not that, 
because from what I understand it works like this :

   1. the first request is made
   2. there is a timeout or something that raises the exception
   3. the errback gets called
   4. it makes a new request
   5. the deferred gets garbage collected
   6. the new request follows the same path

Can anyone confirm that this is correct, or are my defers somehow 
staying alive and not being garbage collected?

Thank you,
Gabriel Rossetti

More information about the Twisted-Python mailing list