summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKa-Ping Yee <ping@zesty.ca>2001-04-11 04:02:05 (GMT)
committerKa-Ping Yee <ping@zesty.ca>2001-04-11 04:02:05 (GMT)
commit285a7e59f308613945ced43889fe12eb993af838 (patch)
tree585e9103b3f91e5e28a09ffbf1efbfbdcf967bb6
parent3f5cc2081394e487c1f2d96f4a2c7d17b8b56435 (diff)
downloadcpython-285a7e59f308613945ced43889fe12eb993af838.zip
cpython-285a7e59f308613945ced43889fe12eb993af838.tar.gz
cpython-285a7e59f308613945ced43889fe12eb993af838.tar.bz2
Add a close_request method to the BaseServer so that the TCPServer class
can close the request connection when it's done handling it.
-rw-r--r--Lib/SocketServer.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/SocketServer.py b/Lib/SocketServer.py
index ec0159a..e5863b5 100644
--- a/Lib/SocketServer.py
+++ b/Lib/SocketServer.py
@@ -154,6 +154,7 @@ class BaseServer:
- verify_request(request, client_address)
- server_close()
- process_request(request, client_address)
+ - close_request(request)
- handle_error()
Methods for derived classes:
@@ -214,6 +215,7 @@ class BaseServer:
self.process_request(request, client_address)
except:
self.handle_error(request, client_address)
+ self.close_request(request)
def verify_request(self, request, client_address):
"""Verify the request. May be overridden.
@@ -243,6 +245,10 @@ class BaseServer:
"""Finish one request by instantiating RequestHandlerClass."""
self.RequestHandlerClass(request, client_address, self)
+ def close_request(self, request):
+ """Called to clean up an individual request."""
+ pass
+
def handle_error(self, request, client_address):
"""Handle an error gracefully. May be overridden.
@@ -277,6 +283,7 @@ class TCPServer(BaseServer):
- get_request() -> request, client_address
- verify_request(request, client_address)
- process_request(request, client_address)
+ - close_request(request)
- handle_error()
Methods for derived classes:
@@ -357,6 +364,10 @@ class TCPServer(BaseServer):
"""
return self.socket.accept()
+ def close_request(self, request):
+ """Called to clean up an individual request."""
+ request.close()
+
class UDPServer(TCPServer):
@@ -376,6 +387,9 @@ class UDPServer(TCPServer):
# No need to call listen() for UDP.
pass
+ def close_request(self, request):
+ # No need to close anything.
+ pass
class ForkingMixIn: