gc.garbage from paramiko

Andrew Bennetts andrew at canonical.com
Wed Feb 8 16:14:56 GMT 2006


On Mon, Feb 06, 2006 at 07:09:24PM +1100, Andrew Bennetts wrote:
> On Fri, Feb 03, 2006 at 10:41:11AM -0800, Robey Pointer wrote:
[...]
> > 
> > Do you have any way to reproduce this outside of Zope?  I tried  
> > running the bzr selftests (and a few other tests, like 'bzr push' to  
> > an sftp site) with 'python -i' and then doing gc.collect() and  
> > looking in gc.garbage, but wasn't able to reproduce it.
> 
> I'm working on this.  I'll let you know when I've got something minimal and
> complete I can share with you.

I have some progress to report.

The garbage occurs during my tests' tearDown.  Specifically, after I stop the
SFTP server process.  This SFTP server is Twisted Conch-based.

At the time tear down happens, there's a live Branch object from the test
hanging around (the result of a
bzrlib.branch.Branch.open('sftp://localhost...')), which is of course still
connected.

One definite result of this set up is that when the server goes away, the
Packetizer.read_all function raises EOFError in the Transport's thread.  You
might be able to reproduce this yourself by simulating this.

I've also found that this code snippet will clear the garbage for me:

        for gbg in gc.garbage:
            if hasattr(gbg, 'auth_handler'):
                gbg.auth_handler = None
        del gbg
        del gc.garbage[:]
        gc.collect()

-Andrew.





More information about the bazaar mailing list