Antoine Pitrou added the comment:
I'm not intending to document the pending() method. Apparently the only people
wanting to use it are/were confused about how exactly to write non-blocking SSL
code, which is not a good hint.
--
resolution: - wont fix
stage: - resolved
status: open -
Bas Wijnen added the comment:
Alexey: please be more civil.
Antoine: In that case, can you please explain how you would recommend me to
implement my use case, where most of my calls are master-initiated and
blocking, but some slave-initiated events must be non-blocking? Should I make
a lot
Steffen Ullrich added the comment:
Data transport in SSL is not done with plain TCP, but with encoded frames
inside TCP. To get decoded data one has to first receive the full frame, even
if one is only interested in the first bytes. Example:
- server does an SSL_write with 200 bytes. This
Antoine Pitrou added the comment:
So to make use of select with SSL the application would have to check first
with pending, if there are already buffered data,
What's the point of checking? Just call SSL_read() and catch the
SSL_ERROR_WANT_{READ,WRITE} to determine that no data is available;
Bas Wijnen added the comment:
After trying to use this, I think ssl.pending is a valuable function that
should be supported and documented.
My use case is a half-synchronous system, where I want most calls to block but
asynchronous events are possible as well. Switching the socket between
Steffen Ullrich added the comment:
What's the point of checking? Just call SSL_read() and catch the
SSL_ERROR_WANT_{READ,WRITE} to determine that no data is available; as a
bonus it also tells you whether you have to select() for read or for write.
A common scenario with non-blocking
Antoine Pitrou added the comment:
I was trying to point out that for SSL enabled sockets this approach
will no longer work and might cause odd stalling of connections,
because select will not show the socket as readable although data are
there for read.
You are right, this is worth
Roundup Robot added the comment:
New changeset b820b1b282b2 by Antoine Pitrou in branch '3.4':
Issue #21430: additions to the description of non-blocking SSL sockets
http://hg.python.org/cpython/rev/b820b1b282b2
New changeset 077e64b23592 by Antoine Pitrou in branch 'default':
Issue #21430:
Alexey Gorshkov added the comment:
Issue #21430: additions to the description of non-blocking SSL sockets
I do not see any mention of .pending() in Your commit.
Is this some personal hate to subject?
Are You going to document this method or not? Documenting it on line of text.
If You are not
Antoine Pitrou added the comment:
For the record, SSLSocket.pending() was added in b59825d9db8f with the commit
message get SSL support to work again. It isn't used anywhere in the stdlib.
It isn't used by asyncio, Tornado or Twisted. It isn't necessary to write
non-blocking SSL applications,
Alexey Gorshkov added the comment:
Ok. As
https://docs.python.org/dev/library/ssl.html#notes-on-non-blocking-sockets
says: Calling select() tells you that the OS-level socket can be read from (or
written to), and here is situation: len(select([ssl_socket],[],[], 0.2)[0])
returns 0, but ssl
Antoine Pitrou added the comment:
Alexey, to quote your own link, here is the proper way:
http://www.perlmonks.org/?node_id=845640
And it is not need to tell about asyncio, Tornado or Twisted.
Of course it is :-) It is generally far better to use an existing non-blocking
I/O framework, than
Alexey added the comment:
Please document this method.
I'm developing xmpp client using python 3.4 and it's ssl module. Stuck with
this same issue for a few days just because of a lack of documentation.
I'm asking you: why should I know about this method not from python
documentation, but
Bas Wijnen added the comment:
The documentation about non-blocking is clear enough, thank you for pointing it
out.
However, I would ask to write anything in there that contains the word
pending. The reason is that I didn't find anything in the documentation,
looked in the source, found the
New submission from Bas Wijnen:
In order to use ssl sockets asynchronously, it is important to use the
pending() method, otherwise the internal buffer will be ignored, and select may
block for new data while it's already waiting. See bug #16976 and
Changes by Ned Deily n...@acm.org:
--
nosy: +pitrou
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21430
___
___
Python-bugs-list mailing list
Changes by Ned Deily n...@acm.org:
--
nosy: +christian.heimes
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21430
___
___
Python-bugs-list mailing
Antoine Pitrou added the comment:
pending() shouldn't be necessary for this. See
https://docs.python.org/dev/library/ssl.html#notes-on-non-blocking-sockets
Generally, when using non-blocking sockets, you first try to read (or write)
and then catch any exceptions that might be raised if the
18 matches
Mail list logo