show instructions for "address already in use" error, and other dev server improvements#2321
Merged
show instructions for "address already in use" error, and other dev server improvements#2321
Conversation
show the loopback IP in addition to the external IP
this avoids issues when reusing a socket descriptor
Always pass the socket as a file descriptor to the server. Show instructions for 'address in use' error. Extract prepare_socket as separate function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I was originally only going to implement the "address already in use" error instructions, but this led me towards some other refactors/fixes. The messages and docs have been updated, and more code has been extracted from
run_simple.run_simplecallssocket.bind, it will catch anyOSErrorand show only the error message without the traceback. Often, users seem to miss the error message in the traceback, and the traceback is not helpful to resolving the issue in this case. If the error is specificallyEADDRINUSE, instructions are shown about identify the other program or changing the port. On macOS, additional instructions are shown to disable "AirPlay Receiver" if the port is 5000.0.0.0.0or::, the "Running on all addresses" message also shows the value that was passed in, hopefully making it clearer that "all addresses" means the same thing. Addditionally, an extra "Running on" line is shown with127.0.0.1or::, hopefully making it clearer that "localhost" and the external IP will both work. There still seems to be some confusion when running in Docker or AWS because users don't understand that the external address still needs to be forwarded to the outside world, but I'm not sure how to resolve that.prepare_socket. Extract the "Running on" message code to a method onBaseWSGIServer. All the difficult code related torun_simpleis now extracted, making it easier to implement a custom run function.run_simplealways binds the socket, assocket.fromfdis available on all supported Python versions and platforms.HTTPServer.server_closeseems to be unreliable, so it's not possible to remove the socket file on close.run_simpleandmake_serverdocs.tox -p. Previously, simultaneous tests would end up hanging because checking for a free port didn't reserve the port for use by the server subprocess. Running all envs in parallel now finishes in ~25 seconds, instead of the ~4 minutes to run them sequentially.