Skip to content
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

bpo-36345: Include the code from Tools/scripts/serve.py for the wsgiref-base web server example #12562

Merged
merged 7 commits into from
Apr 16, 2019

Conversation

matrixise
Copy link
Member

@matrixise matrixise commented Mar 26, 2019

In this PR, I include the code from Tools/scripts/serve.py file but I don't touch the code of the script, just keep it intact because it's not the role of this PR.

https://bugs.python.org/issue36345

@bedevere-bot bedevere-bot added the docs Documentation in the Doc dir label Mar 26, 2019
@matrixise
Copy link
Member Author

@vstinner feel free to review this PR. Thank you so much

@vstinner
Copy link
Member

make check suspicious html SPHINXOPTS="-q -W -j4" failed with the following error on Travis CI:

Warning, treated as error:
[whatsnew/changelog:28] ".. literalinclude:" found in ".. literalinclude::"

I'm not sure why literalinclude is seen as an error?

@JulienPalard: Any idea?

@matrixise
Copy link
Member Author

@JulienPalard @vstinner ?

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

: please review the changes made to this pull request.


# Serve until process is killed
httpd.serve_forever()
Example of a small wsgiref-based web server
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain what the server does? It seems like it serves the directory passed as the first argument on the command line, and accept an optional port number as the second parameter. Proposition:

"Example of a WSGI application serving the directory passed on the command line:"

By the way, would it make sense to modify the example of use the current directory by default, rather than require to pass a directory?

    path = sys.argv[1] if len(sys.argv) > 1 else os.getcwd()

with:

"Example of a WSGI application serving the current directory, accept optional directory and port number on the command line:"

@matrixise
Copy link
Member Author

matrixise commented Apr 15, 2019 via email

@matrixise
Copy link
Member Author

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

: please review the changes made to this pull request.

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

When I tested the example, it wasn't obvious to me how to access the server.

Maybe the script should display somehow the URL http://localhost:8000/?

@@ -25,7 +25,7 @@ def app(environ, respond):
return [b'not found']

if __name__ == '__main__':
path = sys.argv[1]
path = sys.argv[1] if len(sys.argv) > 1 else os.getcwd()
port = int(sys.argv[2]) if len(sys.argv) > 2 else 8000
httpd = simple_server.make_server('', port, app)
print("Serving {} on port {}, control-C to stop".format(path, port))
Copy link
Member

Choose a reason for hiding this comment

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

When I press CTRL+C, I get a ResourceWarning. Please add httpd.server_close() after print("\b\bShutting down."). By the way, I'm not sure that "\b" is supported on Windows. I suggest to remove ""\b\b" to make the script more portable.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

# Serve until process is killed
httpd.serve_forever()
Example of a WSGI application serving the current directory, accept optional
directory and port number on the command line:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
directory and port number on the command line:
directory and port number (default: 8000) on the command line:

@matrixise
Copy link
Member Author

matrixise commented Apr 15, 2019 via email

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM. You can merge it once you will be able to merge changes ;-)

@matrixise matrixise merged commit 2b7f93b into python:master Apr 16, 2019
@matrixise matrixise deleted the bpo-36345-part-3 branch April 16, 2019 12:57
Copy link
Member

@berkerpeksag berkerpeksag left a comment

Choose a reason for hiding this comment

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

Two things:

  1. Only big documentation changes require a NEWS entry.
  2. We only attribute contributors in NEWS entries. It's OK to add your name to Doc/whatsnew/X.Y.rst even if you're a core developer, though.

@vstinner
Copy link
Member

Only big documentation changes require a NEWS entry.

I'm wasn't sure on that point. In case of doubt, I said nothing :-)

We only attribute contributors in NEWS entries. It's OK to add your name to Doc/whatsnew/X.Y.rst even if you're a core developer, though.

Well, Stéphane wrote this PR before he was a core dev :-)

@matrixise
Copy link
Member Author

@berkerpeksag Thank you for your advice, which I will use next time.

@berkerpeksag
Copy link
Member

Well, Stéphane wrote this PR before he was a core dev :-)

I'm not sure how that is an argument here? It could be easily noticed and fixed before merging the PR.

@matrixise welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants