Skip to content

Commit ac75c8a

Browse files
committed
comments
1 parent a34bc70 commit ac75c8a

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

test/common.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,10 +2210,10 @@ def get_zlib_library(self, cmake):
22102210
return rtn
22112211

22122212

2213-
# Run a server and a web page. When a test runs, we tell the server about it,
2213+
# Create a server and a web page. When a test runs, we tell the server about it,
22142214
# which tells the web page, which then opens a window with the test. Doing
22152215
# it this way then allows the page to close() itself when done.
2216-
def harness_server_func(in_queue, out_queue, port):
2216+
def make_test_server(in_queue, out_queue, port):
22172217
class TestServerHandler(SimpleHTTPRequestHandler):
22182218
# Request header handler for default do_GET() path in
22192219
# SimpleHTTPRequestHandler.do_GET(self) below.
@@ -2394,20 +2394,16 @@ def log_request(code=0, size=0):
23942394

23952395
class HttpServerThread(threading.Thread):
23962396
"""A generic thread class to create and run an http server."""
2397-
def __init__(self, server_creator, *server_args):
2397+
def __init__(self, server):
23982398
super().__init__()
2399-
self.server = None
2400-
self.server_creator = server_creator
2401-
self.server_args = server_args
2399+
self.server = server
24022400

24032401
def stop(self):
24042402
"""Shuts down the server if it is running."""
2405-
if self.server:
2406-
self.server.shutdown()
2403+
self.server.shutdown()
24072404

24082405
def run(self):
24092406
"""Creates the server instance and serves forever until stop() is called."""
2410-
self.server = self.server_creator(*self.server_args)
24112407
# Start the server's main loop (this blocks until shutdown() is called)
24122408
self.server.serve_forever()
24132409

@@ -2504,7 +2500,7 @@ def setUpClass(cls):
25042500

25052501
cls.harness_in_queue = queue.Queue()
25062502
cls.harness_out_queue = queue.Queue()
2507-
cls.harness_server = HttpServerThread(harness_server_func, cls.harness_in_queue, cls.harness_out_queue, cls.PORT)
2503+
cls.harness_server = HttpServerThread(make_test_server(cls.harness_in_queue, cls.harness_out_queue, cls.PORT))
25082504
cls.harness_server.start()
25092505

25102506
print(f'[Browser harness server on thread {cls.harness_server.name}]')

test/test_browser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from tools.utils import delete_dir
3232

3333

34-
def test_chunked_synchronous_xhr_server(support_byte_ranges, data, port):
34+
def make_test_chunked_synchronous_xhr_server(support_byte_ranges, data, port):
3535
class ChunkedServerHandler(BaseHTTPRequestHandler):
3636
num_get_connections = 0
3737

@@ -1706,7 +1706,7 @@ def test_chunked_synchronous_xhr(self):
17061706
data = os.urandom(10 * chunkSize + 1) # 10 full chunks and one 1 byte chunk
17071707
checksum = zlib.adler32(data) & 0xffffffff # Python 2 compatibility: force bigint
17081708

1709-
server = HttpServerThread(test_chunked_synchronous_xhr_server, True, data, self.PORT)
1709+
server = HttpServerThread(make_test_chunked_synchronous_xhr_server(True, data, self.PORT))
17101710
server.start()
17111711

17121712
# block until the server is actually ready

0 commit comments

Comments
 (0)