summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2018-05-18 12:21:59 (GMT)
committerPeter Wu <peter@lekensteyn.nl>2018-10-25 11:10:30 (GMT)
commit6e30a04bbe384269fa6a2d51a0a491a0a10b6e69 (patch)
tree34735d2288e5cf977e4354bf7c217f1e0886aa0e
parentfccab7408a53b936fe1a6a527746a5119be71c66 (diff)
downloadNinja-6e30a04bbe384269fa6a2d51a0a491a0a10b6e69.zip
Ninja-6e30a04bbe384269fa6a2d51a0a491a0a10b6e69.tar.gz
Ninja-6e30a04bbe384269fa6a2d51a0a491a0a10b6e69.tar.bz2
browse.py: fix delay with multiple connections
When Firefox opens two TCP connections and sends a request over the second connection, it is not processed until the first one is closed. Use a threaded server to solve this issue. Tested with Python 2.7.15 and 3.6.5. (Also tested with 2.6, but that failed due to lack of argparse.) Link: https://bugs.python.org/issue31639
-rwxr-xr-xsrc/browse.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/browse.py b/src/browse.py
index 64a16f2..1c9c39b 100755
--- a/src/browse.py
+++ b/src/browse.py
@@ -24,8 +24,10 @@ from __future__ import print_function
try:
import http.server as httpserver
+ import socketserver
except ImportError:
import BaseHTTPServer as httpserver
+ import SocketServer as socketserver
import argparse
import cgi
import os
@@ -205,10 +207,14 @@ parser.add_argument('-f', default='build.ninja',
parser.add_argument('initial_target', default='all', nargs='?',
help='Initial target to show (default %(default)s)')
+class HTTPServer(socketserver.ThreadingMixIn, httpserver.HTTPServer):
+ # terminate server immediately when Python exits.
+ daemon_threads = True
+
args = parser.parse_args()
port = args.port
hostname = args.hostname
-httpd = httpserver.HTTPServer((hostname,port), RequestHandler)
+httpd = HTTPServer((hostname,port), RequestHandler)
try:
if hostname == "":
hostname = socket.gethostname()