Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit 6e30a04

Browse files
committed
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
1 parent fccab74 commit 6e30a04

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/browse.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424

2525
try:
2626
import http.server as httpserver
27+
import socketserver
2728
except ImportError:
2829
import BaseHTTPServer as httpserver
30+
import SocketServer as socketserver
2931
import argparse
3032
import cgi
3133
import os
@@ -205,10 +207,14 @@ def log_message(self, format, *args):
205207
parser.add_argument('initial_target', default='all', nargs='?',
206208
help='Initial target to show (default %(default)s)')
207209

210+
class HTTPServer(socketserver.ThreadingMixIn, httpserver.HTTPServer):
211+
# terminate server immediately when Python exits.
212+
daemon_threads = True
213+
208214
args = parser.parse_args()
209215
port = args.port
210216
hostname = args.hostname
211-
httpd = httpserver.HTTPServer((hostname,port), RequestHandler)
217+
httpd = HTTPServer((hostname,port), RequestHandler)
212218
try:
213219
if hostname == "":
214220
hostname = socket.gethostname()

0 commit comments

Comments
 (0)