summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-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: