[Twisted-Python] Re: [Twisted-commits] r17913 - Merge forward

Jean-Paul Calderone exarkun at divmod.com
Tue Aug 22 08:55:27 MDT 2006


On Tue, 22 Aug 2006 01:10:46 -0600, Jonathan Lange <jml at wolfwood.twistedmatrix.com> wrote:
>
>Modified: branches/cleantests-1883-2/twisted/web/test/test_distrib.py
>==============================================================================
>--- branches/cleantests-1883-2/twisted/web/test/test_distrib.py	(original)
>+++ branches/cleantests-1883-2/twisted/web/test/test_distrib.py	Tue Aug 22 01:10:44 2006
>@@ -15,16 +15,37 @@
>                 self.logFile.close()
>             del self.logFile
>
>+
>+def fireOnClose(protocol):
>+    d = defer.Deferred()
>+    oldConnectionLost = protocol.connectionLost
>+    def connectionLost(*a):
>+        oldConnectionLost(*a)
>+        d.callback(None)
>+    protocol.connectionLost = connectionLost
>+    return d
>+
>+
>+class PBServerFactory(pb.PBServerFactory):
>+    onClose = None
>+
>+    def buildProtocol(self, addr):
>+        proto = pb.PBServerFactory.buildProtocol(self, addr)
>+        self.onClose = fireOnClose(proto)
>+        return proto

Would it make sense to use notifyOnDisconnect here, instead of all this
custom scaffolding?

Jean-Paul




More information about the Twisted-Python mailing list