-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
Doc: make serve uses http.server instead of Tools/scripts/server.py #80526
Comments
The Makefile of Doc/ has a @mdk and myself thinking we could deprecate |
I'm ok with modifying "make server" to reuse http.server, but I'm not sure about deprecating Tools/scripts/serve.py. serve.py uses wsgiref which is different than http.server. Does anyone use it? I would prefer to keep it. If you want to remove it, please send an email to python-dev to ask who uses it. "make serve" has been added by bpo-8004 which added Tools/scripts/serve.py. commit e4c74e1
|
I disagree with deprecating serve.py. It is a demo for the wsgiref module. |
If it's appreciated as a demo for wsgiref, wouldn't it be better to move it inside Doc/library/wsgiref.rst? It was written specifically for the Doc/Makefile, it's no longer needed for the Doc/Makefile, so the question pops: is it usefull to anyone? If not it's better to drop it (or move it to the documentation as a nice, time-proven example). |
I agree that if it's a good example of using wsgiref then it should exist in the wsgiref docs as an example. Then that would mean dropping the script and updating the Makefile. |
with your suggestions, I will move the serve.py in the documentation of wsgiref and change Doc/Makefile. |
I suggest to write two separated PRs for each change. |
I propose two PRs. The first one will remove the Tools/scripts/serve.py file and update the Makefile. The second and independent PR just add a new example in the documentation of wsgiref, the example is based on Tools/scripts/serve.py |
I would remove to move the script into the doc in 1 PR and just modify |
Maybe others prefer to do both changes at once. I don't know. |
The files in the Tools directory are installed on user systems by various distributions: for example, in Debian, as part of the python3.x-examples package and by the macOS python.org installer. If you move serve.py, it will no longer be available to end users there. I don't think there is any benefit to removing the file in Tools/scripts and there is some downside; let's leave it there. https://packages.debian.org/sid/all/python3.7-examples/filelist |
Hi Ned, There are 3 PRs, part-0, part-1 and part-2 We can ignore the part-1, this one remove serve.py and the two others are independent. |
Just dropping part-1 is fine with me, thanks. |
Thank you for the merge. Stéphane |
Would it me sense to use ".. literalinclude:: ../../Tools/scripts/serve.py" in the wsgi doc to keep serve.py and and this example up to date? It seems like serve.py is going to stay. |
I actually still think we should remove serve.py as the person who had needed to clean up that directory when we realized we had massive bitrot in /Tools. :) I don't' think that just because Debian packages means we need to continue supporting and maintaining it (e.g. if wsgiref was changed who is going to remember to update this script?). |
Please revert 360e1e4. It's not a good example to put into the documentation. It uses different naming convention. It would only confuse users relatively new to the wsgiref module and WSGI protocol. FileWrapper was supposed to support __getitem__ and __iter__ protocols for compatibility with older Python versions, but its __getiem__ implementation is buggy and is already deprecated. It has no use case in modern Python code. It has zero exception handling and will return a cryptic traceback if mimetype cannot detect type of the file. The examples in the wsgiref documentation already cover most of the cases. There is no need to add more similar ones. |
Berker Peksag:
I looked at other examples: they are nice but far from a "real application". I like the last example which combines multiple wsgiref features and is written like a real application: parse command line arguments, handle CTRL+c, etc.
Would you mind to elaborate? I don't understand what you mean by "naming convention" here, sorry.
Do you mean that app() must not return FileWrapper? How do you return file content in that case? Maybe FileWrapper API should be clarified? It's surprising to read Python 3.8 mentioning compatibility with Python 2.1 :-)
Which kind of exceptions do you expect? The example checks if the file exists for example. |
You can use the same argument for pretty much every example in the stdlib documentation :) wsgiref is a low level module, users should use projects like WebOb instead. Also, a complete example would need to contain basic routing and middleware support (which is not easy to implement correctly)
For example, the response() callable in the example is explicitly documented as start_response() in PEP-3333:
You can read PEP-3333 for more details.
The whole point of the API was to support both __getitem__ and __iter__ protocols at the same time without breaking user code. I've already deprecated the support for __getitem__ protocol (84a13fb) because it wasn't working as expected (it ignores its 'index' argument) Its only valid use case is to read a file chunk by chunk by using its blksize argument, but there are much better ways to achieve the same thing (use os.sendfile() or nginx :))
I'm talking about exceptions that can be raised by the application code, such as the one that I've mentioned (i.e. mimetypes) in my earlier comment. Sorry, but it's not really a good example to put into documentation and it would be much better if we could save our bikeshedding bandwidth to other issues :) |
Ok, thanks Berker for your longer answer. I have no opinion on this example anymore. Stéphane and others: I let you decide how to handle it ;-) |
|
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: