classification
Title: incorrect select documentation
Type: behavior Stage:
Components: Documentation Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, eli.bendersky, exarkun, ezio.melotti, pitrou, python-dev
Priority: normal Keywords:

Created on 2011-05-20 00:23 by exarkun, last changed 2011-05-23 03:12 by eli.bendersky. This issue is now closed.

Messages (10)
msg136350 - (view) Author: Jean-Paul Calderone (exarkun) * (Python committer) Date: 2011-05-20 00:23
http://docs.python.org/py3k/howto/sockets.html#non-blocking-sockets

"And if you put a socket in more than one input list, it will only be (at most) in one output list."


>>> import socket
>>> s = socket.socket()
>>> s.connect(('localhost', 22))
>>> import select
>>> select.select([s], [s], [])
([<socket._socketobject object at 0xb764333c>], [<socket._socketobject object at 0xb764333c>], [])
>>>
msg136410 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-05-20 23:32
The socket HOWTO looks so stupid, obscure and badly written that it should IMO be deleted.
msg136421 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2011-05-21 06:46
Antoine, can you be more specific? I recall finding it quite useful when first learning Python. Perhaps it can be improved in a few specific places, but overall I don't think it's a bad document.
msg136422 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2011-05-21 07:22
This issue Jean-Paul raises seems to be a plain error. select() certainly can return that some given socket is both readable and writable (this is explicitly discussed in Steven's APitUE $14.5), and I see no evidence in the implementation of Python's selectmodule.c that it somehow violates the output of system's select() to behave otherwise.
msg136429 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-05-21 11:01
Well, my main issue with this document is that it doesn't seem to have a well-defined destination:
- people who know sockets won't learn anything from it
- but people who don't know sockets will probably find it clear as mud (for example, what's an "INET" or "STREAM" socket? what's "select"?)

I have other issues, such as the style/tone it's written in. I'm sure the author had fun writing it but it doesn't fit well with the rest of the documentation. Also, the author gives a lot of "advice" without really giving an example ("if somewhere in those input lists of sockets is one which has died a nasty death, the select will fail" -> is that really true? what is a "nasty death" and how is that supposed to happen? couldn't the author have put a 3-line example to demonstrate this supposed drawback and how it manifests?).

And, finally, many statements seem arbitrary ("There’s no question that the fastest sockets code uses non-blocking sockets and select to multiplex them") or plain wrong ("threading support in Unixes varies both in API and quality. So the normal Unix solution is to fork a subprocess to deal with each connection"). I don't think giving misleading advice to users is really a good idea. And suggesting beginners they use non-blocking sockets without even *showing* how (or pointing to asyncore or Twisted) is a very bad idea. select() is not enough, you still have to be prepared to get EAGAIN or EWOULDBLOCK when calling recv() or send() (i.e. select() can give false positives).

Oh and I think it's obsolete too, because the "class mysocket" concatenates the output of recv() with a str rather than a bytes object. Not to mention that features of the "class mysocket" can be had using a buffered socket.makefile() instead of writing custom code.
msg136448 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2011-05-21 14:59
It makes sense to bring this up for discussion on pydev, then. Perhaps it will be decided to remove this document from the official documentation, possibly relegating it to the Wiki.

In the meantime, is there an objection to removing the incorrect statement Jean-Paul mentioned from the doc? It's obviously incorrect both in theory and practice.
msg136449 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-05-21 15:07
> It makes sense to bring this up for discussion on pydev, then.

Ok, done.

> In the meantime, is there an objection to removing the incorrect
> statement Jean-Paul mentioned from the doc?

Well, no.
msg136502 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-05-22 03:49
New changeset c0a3e17e677f by Eli Bendersky in branch '2.7':
Issue 12126: removing incorrect claim about return value of select
http://hg.python.org/cpython/rev/c0a3e17e677f
msg136503 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-05-22 04:00
New changeset ca4d9ccb6894 by Eli Bendersky in branch '3.1':
Issue 12126: removing incorrect claim about return value of select
http://hg.python.org/cpython/rev/ca4d9ccb6894

New changeset c26d551b5ff6 by Eli Bendersky in branch '3.2':
Issue 12126: removing incorrect claim about return value of select
http://hg.python.org/cpython/rev/c26d551b5ff6

New changeset 53242ca6df28 by Eli Bendersky in branch 'default':
Issue 12126: removing incorrect claim about return value of select
http://hg.python.org/cpython/rev/53242ca6df28
msg136586 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2011-05-23 03:12
Closing this issue, since it specifically refers to the select error which was fixed. Tracking the removal of the sockets howto document can be done elsewhere.
History
Date User Action Args
2011-05-23 03:12:45eli.benderskysetstatus: open -> closed
resolution: fixed
messages: + msg136586
2011-05-22 04:00:12python-devsetmessages: + msg136503
2011-05-22 03:49:21python-devsetnosy: + python-dev
messages: + msg136502
2011-05-21 15:07:49pitrousetmessages: + msg136449
2011-05-21 14:59:47eli.benderskysetmessages: + msg136448
2011-05-21 11:01:27pitrousetmessages: + msg136429
2011-05-21 07:22:36eli.benderskysetmessages: + msg136422
2011-05-21 06:46:03eli.benderskysetnosy: + eli.bendersky
messages: + msg136421
2011-05-20 23:33:42ezio.melottisetnosy: + ezio.melotti
2011-05-20 23:32:08pitrousetnosy: + pitrou
messages: + msg136410
2011-05-20 00:23:51exarkuncreate