validate: Make the HTTP server multi-threaded

Avoids having one test blocking all other tests
This commit is contained in:
Edward Hervey 2017-03-02 17:35:22 +01:00 committed by Edward Hervey
parent 49271bc721
commit 99cade5ba4

View file

@ -35,6 +35,8 @@ __all__ = ["RangeHTTPRequestHandler"]
import os
import sys
from socketserver import ThreadingMixIn
import posixpath
import http.server
import urllib.parse
@ -47,6 +49,8 @@ import time
_bandwidth = 0
class ThreadingSimpleServer(ThreadingMixIn, http.server.HTTPServer):
pass
class RangeHTTPRequestHandler(http.server.BaseHTTPRequestHandler):
@ -280,5 +284,5 @@ def test(handler_class = RangeHTTPRequestHandler,server_class = http.server.HTTP
http.server.test(handler_class, server_class)
if __name__ == "__main__":
httpd = http.server.HTTPServer(("0.0.0.0", int(sys.argv[1])), RangeHTTPRequestHandler)
httpd = ThreadingSimpleServer(("0.0.0.0", int(sys.argv[1])), RangeHTTPRequestHandler)
httpd.serve_forever()