-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Asyncio socket-level methods do not support SSLSocket #122706
Comments
I'm wondering if this isn't a mistake in the docs, but a bug in def _check_ssl_socket(sock):
if ssl is not None and isinstance(sock, ssl.SSLSocket):
raise TypeError("Socket cannot be of type SSLSocket") It doesn't make much sense to me to raise the error when |
The try:
import ssl
except ImportError: # pragma: no cover
ssl = None |
Yup, that's why the check is there, but I was wondering wondering if it was a mistake. Anyways, I take that back, this is a docs mistake. |
Fixed by #128092 |
(cherry picked from commit 19c5134) Co-authored-by: Kumar Aditya <[email protected]>
(cherry picked from commit 19c5134) Co-authored-by: Kumar Aditya <[email protected]>
Attempting to use a
SSLSocket
with theasyncio.loop.sock_sendall
method and the other socket-level async functions raises the following error:This can be reproduced by the following if
socket
is aSSLSocket
:However, the ssl-nonblocking section of the docs says the following:
"See also: The asyncio module supports non-blocking SSL sockets and provides a higher level API. It polls for events using the selectors module and handles SSLWantWriteError, SSLWantReadError and BlockingIOError exceptions. It runs the SSL handshake asynchronously as well."
Is this section specifically referencing the streams API as the SSL-compatible asyncio API? The current wording is unclear and suggests to me that non-blocking
SSLSocket
sockets are supported by asyncio, despite the error above. Is there a different section that specifies thatSSLSocket
is not supported by the socket-level asyncio API?Linked PRs
The text was updated successfully, but these errors were encountered: