Commit d699cde9 authored by Guido van Rossum's avatar Guido van Rossum

SF bug #471720: ThreadingMixIn/TCPServer forgets close

Solved with a helper method that calls finish_request() and then
close_request().  The code is by Max Neunhöffer.
parent efd35450
...@@ -448,10 +448,15 @@ class ForkingMixIn: ...@@ -448,10 +448,15 @@ class ForkingMixIn:
class ThreadingMixIn: class ThreadingMixIn:
"""Mix-in class to handle each request in a new thread.""" """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): def process_request(self, request, client_address):
"""Start a new thread to process the request.""" """Start a new thread to process the request."""
import threading import threading
t = threading.Thread(target = self.finish_request, t = threading.Thread(target = self.process_request_thread,
args = (request, client_address)) args = (request, client_address))
t.start() t.start()
......
...@@ -296,6 +296,7 @@ Takahiro Nakayama ...@@ -296,6 +296,7 @@ Takahiro Nakayama
Travers Naran Travers Naran
Fredrik Nehr Fredrik Nehr
Chad Netzer Chad Netzer
Max Neunhffer
George Neville-Neil George Neville-Neil
Oscar Nierstrasz Oscar Nierstrasz
Hrvoje Niksic Hrvoje Niksic
......
...@@ -86,6 +86,9 @@ Library ...@@ -86,6 +86,9 @@ Library
which indicates whether output is intended for the header 'Q' which indicates whether output is intended for the header 'Q'
encoding. encoding.
- The SocketServer.ThreadingMixIn class now closes the request after
finish_request() returns. (Not when it errors out though.)
Tools/Demos Tools/Demos
- Demo/dns was removed. It no longer serves any purpose; a package - Demo/dns was removed. It no longer serves any purpose; a package
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment