diff Lib/SocketServer.py @ 54928:ffd7cf5c7285 legacy-trunk

http://bugs.python.org/issue6267 Cumulative patch to http and xmlrpc
author Kristján Valur Jónsson <kristjan@ccpgames.com>
date Sun, 28 Jun 2009 21:04:17 +0000
parents a20a377cc327
children 01af7b52e0db
line wrap: on
line diff
--- a/Lib/SocketServer.py	Sun Jun 28 19:27:55 2009 +0000
+++ b/Lib/SocketServer.py	Sun Jun 28 21:04:17 2009 +0000
@@ -445,6 +445,7 @@
 
     def close_request(self, request):
         """Called to clean up an individual request."""
+        request.shutdown(socket.SHUT_WR)
         request.close()
 
 
@@ -610,12 +611,11 @@
         self.request = request
         self.client_address = client_address
         self.server = server
+        self.setup()
         try:
-            self.setup()
             self.handle()
+        finally:
             self.finish()
-        finally:
-            sys.exc_traceback = None    # Help garbage collection
 
     def setup(self):
         pass
@@ -649,12 +649,17 @@
     rbufsize = -1
     wbufsize = 0
 
+    # A timeout to apply to the request socket, if not None.
+    timeout = None
+
     # Disable nagle algoritm for this socket, if True.
     # Use only when wbufsize != 0, to avoid small packets.
     disable_nagle_algorithm = False
 
     def setup(self):
         self.connection = self.request
+        if self.timeout is not None:
+            self.connection.settimeout(self.timeout)
         if self.disable_nagle_algorithm:
             self.connection.setsockopt(socket.IPPROTO_TCP,
                                        socket.TCP_NODELAY, True)