-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[testing] Use threads for the http servers. #25141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remind me why "sub processes aren't allowed."?
test/common.py
Outdated
|
||
class ServerThread(threading.Thread): | ||
"""A generic thread class to create and run a server.""" | ||
def __init__(self, server_creator, *server_args): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
server_ctor
or server_constructor
.. or maybe server_class
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It takes a function, so I don't think those names work.
Workers in the pool are already daemon processes and do not allow you to create sub processes. More on the daemonic stuff: https://docs.python.org/3/library/multiprocessing.html#multiprocessing.Process.daemon |
This is in preparation for the parallel browser tests where sub processes aren't allowed. The server no longer changes the directory during tests, since we can now rely on the test runner changing the directory (same process).
724a71c
to
a34bc70
Compare
test/common.py
Outdated
|
||
cls.harness_in_queue = queue.Queue() | ||
cls.harness_out_queue = queue.Queue() | ||
cls.harness_server = HttpServerThread(harness_server_func, cls.harness_in_queue, cls.harness_out_queue, cls.PORT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we at least rename harness_server_func
to something like make_test_server
or make_test_harness
since that function now returns that server rather than running it?
This is in preparation for the parallel browser tests where sub processes aren't allowed.
The server no longer changes the directory during tests, since we can now rely on the test runner changing the directory (same process).