diff options
author | Julien Palard <julien@palard.fr> | 2018-03-23 16:40:33 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-23 16:40:33 (GMT) |
commit | 8bcfa02e4b1b65634e526e197588bc600674c80b (patch) | |
tree | 78f5c33e9f31babbc38a317203be86cb7a8eb6ed /Lib/http | |
parent | a0a42d22d8dff0ec6ea9daa4d9c9e9399f9b4e6c (diff) | |
download | cpython-8bcfa02e4b1b65634e526e197588bc600674c80b.zip cpython-8bcfa02e4b1b65634e526e197588bc600674c80b.tar.gz cpython-8bcfa02e4b1b65634e526e197588bc600674c80b.tar.bz2 |
bpo-31639: Use threads in http.server module. (GH-5018)
Diffstat (limited to 'Lib/http')
-rw-r--r-- | Lib/http/server.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/http/server.py b/Lib/http/server.py index 502bce0..a2726ab 100644 --- a/Lib/http/server.py +++ b/Lib/http/server.py @@ -83,7 +83,7 @@ XXX To do: __version__ = "0.6" __all__ = [ - "HTTPServer", "BaseHTTPRequestHandler", + "HTTPServer", "ThreadedHTTPServer", "BaseHTTPRequestHandler", "SimpleHTTPRequestHandler", "CGIHTTPRequestHandler", ] @@ -140,6 +140,10 @@ class HTTPServer(socketserver.TCPServer): self.server_port = port +class ThreadedHTTPServer(socketserver.ThreadingMixIn, HTTPServer): + daemon_threads = True + + class BaseHTTPRequestHandler(socketserver.StreamRequestHandler): """HTTP request handler base class. @@ -1213,7 +1217,8 @@ class CGIHTTPRequestHandler(SimpleHTTPRequestHandler): def test(HandlerClass=BaseHTTPRequestHandler, - ServerClass=HTTPServer, protocol="HTTP/1.0", port=8000, bind=""): + ServerClass=ThreadedHTTPServer, + protocol="HTTP/1.0", port=8000, bind=""): """Test the HTTP request handler class. This runs an HTTP server on port 8000 (or the port argument). |