[Twisted-Python] [PATCH] HTTP server fix for the FD problem

Andrew Bennetts andrew-twisted at puzzling.org
Sun May 11 08:08:57 MDT 2003


I shouldn't make last-minute untested changes :(

On Sun, May 11, 2003 at 07:28:42PM +1000, Andrew Bennetts wrote:
[...]
> +def TimeoutWrapper(protocolClass):
> +    class _TimeoutProtocol(protocolClass, object):
> +        """Protocol that automatically disconnects when the connection is idle.
> +        
> +        Stability: Unstable
> +        """
> +
> +        def connectionMade(self):
> +            self.timeoutCall = None
> +            if getattr(self, 'timeoutPeriod', None):

This last line here should of course have a "is not None" in it:
+            if getattr(self, 'timeoutPeriod', None) is not None:

Also, test_http.py needs to be patched:

Index: twisted/test/test_http.py
===================================================================
RCS file: /cvs/Twisted/twisted/test/test_http.py,v
retrieving revision 1.18
diff -u -r1.18 test_http.py
--- twisted/test/test_http.py   18 Feb 2003 12:34:53 -0000      1.18
+++ twisted/test/test_http.py   11 May 2003 14:07:49 -0000
@@ -102,6 +102,7 @@
     def testBuffer(self):
         b = StringIOWithoutClosing()
         a = http.HTTPChannel()
+        a.timeoutPeriod = 60
         a.requestFactory = DummyHTTPHandler
         a.makeConnection(protocol.FileWrapper(b))
         # one byte at a time, to stress it.
@@ -198,6 +199,7 @@
 
     def testLoopback(self):
         server = http.HTTPChannel()
+        server.timeoutPeriod = 60
         server.requestFactory = DummyHTTPHandler
         client = LoopbackHTTPClient()
         client.handleResponse = self._handleResponse
@@ -277,6 +279,7 @@
         httpRequest = httpRequest.replace("\n", "\r\n")
         b = StringIOWithoutClosing()
         a = http.HTTPChannel()
+        a.timeoutPeriod = 60
         a.requestFactory = requestClass
         a.makeConnection(protocol.FileWrapper(b))
         # one byte at a time, to stress it.


-Andrew.





More information about the Twisted-Python mailing list