msg223909 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2014-07-24 23:24 |
The sock_xxx() methods of asyncio.BaseEventLoop don't make the socket non-blocking, and the documentation doesn't require that sockets are already set to non-blocking mode. It looks like a bug, at least in the documentation. If these methods should make the sockets non-blocking, should they also restore the previous timeout (blocking mode) at exit? ssl.SSLSocket.do_handshake(block=True) makes temporary the socket blocking, and then restore the previous timeout. |
|
|
msg223914 - (view) |
Author: Guido van Rossum (gvanrossum) *  |
Date: 2014-07-25 02:07 |
PEP 3156 is clear: "The socket argument has to be a non-blocking socket." So it's a documentation issue. |
|
|
msg224185 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2014-07-28 20:32 |
Ok, I will write a a patch to raise an exception in debug mode if the socket is in blocking mode. |
|
|
msg224253 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2014-07-29 21:11 |
New changeset 7e70ec207889 by Victor Stinner in branch '3.4': Close #22063: socket operations (socket,recv, sock_sendall, sock_connect, http://hg.python.org/cpython/rev/7e70ec207889 New changeset 8967d9a1bc17 by Victor Stinner in branch 'default': Merge with Python 3.4 (asyncio) http://hg.python.org/cpython/rev/8967d9a1bc17 |
|
|
msg224254 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2014-07-29 21:12 |
New changeset 95ceec174baf by Victor Stinner in branch '3.4': Issue #22063: Mention in asyncio documentation that socket operations require http://hg.python.org/cpython/rev/95ceec174baf New changeset 741e58bcaa65 by Victor Stinner in branch 'default': (Merge 3.4) Issue #22063: Mention in asyncio documentation that socket http://hg.python.org/cpython/rev/741e58bcaa65 |
|
|
msg224368 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2014-07-31 00:58 |
I reopen the issue because the documentation is not correct. Using the proactor event loop, the socket doesn't need to be non-blocking. Should we mention it? Another issue: BaseEventLoop.connect_read_pipe() doc says that the pipe is set to non-blocking mode, whereas BaseEventLoop.connect_read_pipe() doc requires that the pipe is already in non-blocking mode. On UNIX, both methods set the pipe to non-blocking mode. It may also help to mention directly in BaseEventLoop.connect_read_pipe() doc that it is not available on Windows when using the SelectorEventLoop. |
|
|
msg224375 - (view) |
Author: Guido van Rossum (gvanrossum) *  |
Date: 2014-07-31 02:44 |
Hm. I think there are two different situations. One is where the app creates a socket (or other I/O thingie), passes it off to asyncio, and then asyncio owns it. This is the case for pipes and also for the optional sock parameter for create_connection(). In these cases I think it is more robust of asyncio configures the FD for its own needs. The other case is where the app and asyncio share the socket. This is the case for e.g. sock_recv(). In this case I think it should be the app's responsibility to configure it properly. Asyncio can check in debug mode, but otherwise it may be too expensive to check. (Checking a socket object is actually fine, just check that gettimeout() returns 0; but checking a FD would require a syscall so don't do that in debug mode.) So the docs for connect_write_pipe() have a bug. :-) |
|
|
msg225897 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2014-08-25 21:23 |
New changeset 877c8442b992 by Victor Stinner in branch '3.4': asyncio: sync with Tulip http://hg.python.org/cpython/rev/877c8442b992 New changeset 63cabfde945f by Victor Stinner in branch 'default': (Merge 3.4) asyncio: sync with Tulip http://hg.python.org/cpython/rev/63cabfde945f |
|
|
msg225899 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2014-08-25 22:44 |
sock_nonblocking_doc.patch: fix connect_read_pipe/connect_write_pipe, sock_sendall/sock_recv/sock_accept/sock_connect documentation to mention that the non-blocking behaviour is specific to the SelectorEventLoop. |
|
|
msg225901 - (view) |
Author: Guido van Rossum (gvanrossum) *  |
Date: 2014-08-25 22:58 |
LGTM |
|
|
msg225903 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2014-08-25 23:00 |
> It may also help to mention directly in BaseEventLoop.connect_read_pipe() doc that it is not available on Windows when using the SelectorEventLoop. I created the issue #22275 for this point. |
|
|
msg225904 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2014-08-25 23:02 |
New changeset b94da2b69d13 by Victor Stinner in branch '3.4': Issue #22063: Fix asyncio documentation of socket and pipe operations regarding http://hg.python.org/cpython/rev/b94da2b69d13 New changeset 74236c8bf064 by Victor Stinner in branch 'default': (Merge 3.4) Issue #22063: Fix asyncio documentation of socket and pipe http://hg.python.org/cpython/rev/74236c8bf064 |
|
|
msg225905 - (view) |
Author: STINNER Victor (vstinner) *  |
Date: 2014-08-25 23:04 |
> LGTM Thanks for the review. I commited sock_nonblocking_doc.patch. This issue is now fully fixed. It was more tricky than what I expected. |
|
|