summaryrefslogtreecommitdiffstats
path: root/Lib/socketserver.py
diff options
context:
space:
mode:
authorKristján Valur Jónsson <kristjan@ccpgames.com>2009-07-01 10:01:31 (GMT)
committerKristján Valur Jónsson <kristjan@ccpgames.com>2009-07-01 10:01:31 (GMT)
commit985fc6a3041e992448827fd2b496cc5b3f344b28 (patch)
tree776a30cdbfe53180711389c95fa550d77c2e65a2 /Lib/socketserver.py
parentfae45ed87441f54b10607081e0455acd9e5ad630 (diff)
downloadcpython-985fc6a3041e992448827fd2b496cc5b3f344b28.zip
cpython-985fc6a3041e992448827fd2b496cc5b3f344b28.tar.gz
cpython-985fc6a3041e992448827fd2b496cc5b3f344b28.tar.bz2
http://bugs.python.org/issue6267
porting revision 73638 to py3k
Diffstat (limited to 'Lib/socketserver.py')
-rw-r--r--Lib/socketserver.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/socketserver.py b/Lib/socketserver.py
index 2ed50b9..e5f5778 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()
@@ -611,8 +612,10 @@ class BaseRequestHandler:
self.client_address = client_address
self.server = server
self.setup()
- self.handle()
- self.finish()
+ try:
+ self.handle()
+ finally:
+ self.finish()
def setup(self):
pass
@@ -646,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)