diff options
author | Avery Pennarun <apenwarr@gmail.com> | 2010-12-09 18:31:41 -0800 |
---|---|---|
committer | Avery Pennarun <apenwarr@gmail.com> | 2010-12-09 19:20:06 -0800 |
commit | a497132c014002c4689526b98c5afe564326f9af (patch) | |
tree | fe358edd4c16e11f712bd1331e50d3ef4988db62 | |
parent | 735460084991336dbd8e0c054bc939b209014d42 (diff) |
Add debug messages for counting SockWrapper objects.
You can use this to confirm that a memory leak exists.
-rw-r--r-- | ssnet.py | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -75,8 +75,12 @@ def _try_peername(sock): return 'unknown' +_swcount = 0 class SockWrapper: def __init__(self, rsock, wsock, connect_to=None, peername=None): + global _swcount + _swcount += 1 + debug3('creating new SockWrapper (%d now exist\n)' % _swcount) self.exc = None self.rsock = rsock self.wsock = wsock @@ -87,7 +91,9 @@ class SockWrapper: self.try_connect() def __del__(self): - debug1('%r: deleting\n' % self) + global _swcount + _swcount -= 1 + debug1('%r: deleting (%d remain)\n' % (self, _swcount)) if self.exc: debug1('%r: error was: %r\n' % (self, self.exc)) |