[Twisted-Python] Woven application, objects not collected.

Syver Enstad syver at inout.no
Tue Nov 25 06:56:26 MST 2003


Andrew Bennetts <andrew at puzzling.org> writes:

> On Wed, Nov 26, 2003 at 12:13:38AM +1100, Andrew Bennetts wrote:
> > 
> > If we can find a good enough test case, we might be able to write a unit
> > test to trigger it and then check gc.garbage, so that we can include it in
> > the test suite and stop it from happening again.
> 
> Thinking about this further, I just wrote the following hack for trial:
> 
> bash-2.05b$ cvs diff -u twisted/scripts/trial.py
> Index: twisted/scripts/trial.py
> ===================================================================
> RCS file: /cvs/Twisted/twisted/scripts/trial.py,v
> retrieving revision 1.51
> diff -u -r1.51 trial.py
> --- twisted/scripts/trial.py    17 Oct 2003 21:48:16 -0000      1.51
> +++ twisted/scripts/trial.py    25 Nov 2003 13:17:02 -0000
> @@ -328,6 +328,11 @@
>                                 suite.run, reporter, config['random'])
>          else:
>              suite.run(reporter, config['random'])
> +    import gc
> +    gc.collect()
> +    if gc.garbage:
> +        print "GARBAGE: %d objects" % len(gc.garbage)
> +        print "GARBAGE: " + repr(gc.garbage)
>      sys.exit(not reporter.allPassed())
>  
>  if __name__ == '__main__':
> 
> 
> I've only just started playing with this, but none of the web or woven tests
> show anything.  test_pb seems to leak a whole bunch of stuff, though...

The deferreds that are leaking are coming from pb (aReferenceable.callRemote).

I think that a minimal test case to show the problem would be: (I'll test this later, I have to go in five minutes time).

Pseudo code:
class Page:
   def initialize(self, ...):
       self._deferred = defer.succeed([1, 2, 3])

   def wmfactory_oneTwoThree(self, request):
       return self._deferred


My guess is that self._deferred will end up in gc.garbage.

I will test this later.







More information about the Twisted-Python mailing list