summaryrefslogtreecommitdiffstats
path: root/Lib/SocketServer.py
diff options
context:
space:
mode:
authorKristján Valur Jónsson <kristjan@ccpgames.com>2009-06-28 21:04:17 (GMT)
committerKristján Valur Jónsson <kristjan@ccpgames.com>2009-06-28 21:04:17 (GMT)
commite007860b8b3609ce0bc62b1780efaa06241520bd (patch)
tree687961d29bff1d936ed949cf591bbe8285d9e54d /Lib/SocketServer.py
parent552e7a7e2f526fa0637a3e14f47354c567dfe26e (diff)
downloadcpython-e007860b8b3609ce0bc62b1780efaa06241520bd.zip
cpython-e007860b8b3609ce0bc62b1780efaa06241520bd.tar.gz
cpython-e007860b8b3609ce0bc62b1780efaa06241520bd.tar.bz2
http://bugs.python.org/issue6267
Cumulative patch to http and xmlrpc
Diffstat (limited to 'Lib/SocketServer.py')
-rw-r--r--Lib/SocketServer.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/SocketServer.py b/Lib/SocketServer.py
index 7a25d0f..73cd219 100644
--- a/Lib/SocketServer.py
+++ b/Lib/SocketServer.py
@@ -445,6 +445,7 @@ class TCPServer(BaseServer):
def close_request(self, request):
"""Called to clean up an individual request."""
+ request.shutdown(socket.SHUT_WR)
request.close()
@@ -610,12 +611,11 @@ class BaseRequestHandler:
self.request = request
self.client_address = client_address
self.server = server
+ self.setup()
try:
- self.setup()
self.handle()
- self.finish()
finally:
- sys.exc_traceback = None # Help garbage collection
+ self.finish()
def setup(self):
pass
@@ -649,12 +649,17 @@ class StreamRequestHandler(BaseRequestHandler):
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)