Skip to content

Conversation

QuLogic
Copy link
Contributor

@QuLogic QuLogic commented Sep 23, 2024

This allows running tests in parallel without running into "Port already in use" errors.

Copy link
Member

@martindurant martindurant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first glance all looks well here, but I have not yet reviewed in detail.

I have one main comment for you to consider before moving on.

return self._respond(200, data=json.dumps({"path": self.path}).encode())
if "redirect" in self.headers and file_path != "/index/realfile":
new_url = f"http://127.0.0.1:{port}/index/realfile"
new_url = f"http://127.0.0.1:{self.server.server_port}/index/realfile"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.server.realfile?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.server is the HTTPServer, not the server fixture, and doesn't have a realfile attribute. But this could probably use _make_realfile instead.

th.start()
try:
yield f"http://127.0.0.1:{port}"
yield f"http://127.0.0.1:{httpd.server_port}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are choosing to become port agnostic, this may be a good time to also become server address agnostic. httpd.server_name should be populated here, and might be other than the standard loopback, e.g., for systems that are IPv6 only.

@QuLogic QuLogic force-pushed the no-hardcode-ports branch 3 times, most recently from 768c381 to 41053a2 Compare September 30, 2024 21:36
@martindurant
Copy link
Member

Test failures with a bunch of "Cannot connect to host 0.0.0.0:50610" look real - but only on windows.

@QuLogic
Copy link
Contributor Author

QuLogic commented Oct 1, 2024

Unfortunately, it looks like HTTPServer.server_address doesn't expand to a concrete address, and I guess unlike Linux, Windows doesn't allow connecting to 0.0.0.0. But maybe I should have used server_name?

This allows running tests in parallel without running into "Port already
in use" errors.
@QuLogic QuLogic force-pushed the no-hardcode-ports branch from 41053a2 to b52d782 Compare October 1, 2024 01:43
@martindurant
Copy link
Member

Well done :)

@martindurant martindurant merged commit 4b4195d into fsspec:master Oct 1, 2024
11 checks passed
@QuLogic QuLogic deleted the no-hardcode-ports branch October 1, 2024 21:49
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.

2 participants