]> granicus.if.org Git - python/commitdiff
SF bug #471720: ThreadingMixIn/TCPServer forgets close
authorGuido van Rossum <guido@python.org>
Thu, 18 Oct 2001 18:02:07 +0000 (18:02 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 18 Oct 2001 18:02:07 +0000 (18:02 +0000)
Solved with a helper method that calls finish_request() and then
close_request().  The code is by Max Neunhöffer.

Lib/SocketServer.py
Misc/ACKS
Misc/NEWS

index 00064ba89680dfa37ad6f78fe4216a8cb0b735ea..5128e17548fcd5e73eb1b65f206352a1d8580ba5 100644 (file)
@@ -448,10 +448,15 @@ class ForkingMixIn:
 class ThreadingMixIn:
     """Mix-in class to handle each request in a new thread."""
 
+    def process_request_thread(self, request, client_address):
+        """Same as in BaseServer but as a thread."""
+        self.finish_request(request, client_address)
+        self.close_request(request)
+
     def process_request(self, request, client_address):
         """Start a new thread to process the request."""
         import threading
-        t = threading.Thread(target = self.finish_request,
+        t = threading.Thread(target = self.process_request_thread,
                              args = (request, client_address))
         t.start()
 
index e7400e9e51a72837e709064b8dd30fd5a7dc9405..b17219a9508d89cad1f2c55619636dcb295f8983 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -296,6 +296,7 @@ Takahiro Nakayama
 Travers Naran
 Fredrik Nehr
 Chad Netzer
+Max Neunhöffer
 George Neville-Neil
 Oscar Nierstrasz
 Hrvoje Niksic
index e2e9683344a68a46fed5c975607693f6f3af07d7..e89b789ba13d23e24f5c89d08ef2d0363208f49d 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -86,6 +86,9 @@ Library
   which indicates whether output is intended for the header 'Q'
   encoding.
 
+- The SocketServer.ThreadingMixIn class now closes the request after
+  finish_request() returns.  (Not when it errors out though.)
+
 Tools/Demos
 
 - Demo/dns was removed.  It no longer serves any purpose; a package