Skip to content

[testing] Use threads for the http servers. - #25141

Merged
brendandahl merged 2 commits into
emscripten-core:mainfrom
brendandahl:threaded-server
Sep 3, 2025
Merged

brendandahl merged 2 commits into
emscripten-core:mainfrom
brendandahl:threaded-server

Conversation

@brendandahl

Copy link
Copy Markdown
Collaborator

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).

@sbc100 sbc100 left a comment

Copy link
Copy Markdown
Collaborator

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."?

Comment thread test/test_browser.py Outdated
Comment thread test/common.py Outdated
Comment thread test/common.py Outdated
Comment thread test/common.py Outdated
Comment thread 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):

Copy link
Copy Markdown
Collaborator

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?

Copy link
Copy Markdown
Collaborator Author

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.

Comment thread test/common.py Outdated
@brendandahl

Copy link
Copy Markdown
Collaborator Author

Can you remind me why "sub processes aren't allowed."?

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).
Comment thread 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)

Copy link
Copy Markdown
Collaborator

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?

@brendandahl
brendandahl merged commit c70edc6 into emscripten-core:main Sep 3, 2025
30 checks passed
inolen pushed a commit to inolen/emscripten that referenced this pull request Feb 13, 2026
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants