[Twisted-Python] doStart count leak?
Andrew Bennetts
andrew-twisted at puzzling.org
Wed Jan 1 08:16:14 MST 2003
Tv pointed this out on irc:
<Tv> _moshez: Are you guru enough to grok BaseConnector?
<Tv> Reconnects (calling connector.connect() in connectionLost/Failed) make
it leak numPorts and never shutdown the factory.
Here is a diff for test_tcp that (I think) reveals this bug:
diff -u -r1.13 test_tcp.py
--- twisted/test/test_tcp.py 6 Aug 2002 17:12:42 -0000 1.13
+++ twisted/test/test_tcp.py 1 Jan 2003 14:59:55 -0000
@@ -56,6 +56,7 @@
class MyClientFactory(protocol.ClientFactory):
failed = 0
+ stopped = 0
def buildProtocol(self, addr):
p = MyProtocol()
@@ -69,6 +70,9 @@
def clientConnectionLost(self, connector, reason):
self.lostReason = reason
+ def stopFactory(self):
+ self.stopped = 1
+
class LoopbackTestCase(unittest.TestCase):
"""Test loopback connections."""
@@ -274,6 +278,7 @@
p = factory.protocol
self.assertEquals((p.made, p.closed), (1, 1))
factory.reason.trap(error.ConnectionRefusedError)
+ self.assertEquals(factory.stopped, 1)
class CannotBindTestCase (unittest.TestCase):
-Andrew.
More information about the Twisted-Python
mailing list