X Tutup
The Wayback Machine - https://web.archive.org/web/20260129200524/https://github.com/python/cpython/pull/94062
Skip to content

Conversation

@sileht
Copy link
Contributor

@sileht sileht commented Jun 21, 2022

The asyncio ssl error handling will now set a message for
ConnectionResetError exception.

@bedevere-bot
Copy link

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

The asyncio ssl error handling will now set a message for
ConnectionResetError exception.
@sileht sileht force-pushed the ConnectionError branch from 66c3d61 to bccaea8 Compare June 21, 2022 14:28
@sileht
Copy link
Contributor Author

sileht commented Jun 28, 2022

@vstinner can you take a look?

if self._state == SSLProtocolState.DO_HANDSHAKE:
self._on_handshake_complete(ConnectionResetError)
self._on_handshake_complete(
ConnectionResetError("SSL Connection reset by peer"))
Copy link
Member

@vstinner vstinner Jun 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced that it's always the case. SSLProtocol._do_shutdown() calls _call_eof_received().

If you want to pass a reason, I suggest adding a parameter to _call_eof_received(). And maybe add a private _eof_received() function which accepts a message. For example, eof_received() can simply call _eof_received() with a default message.

close() also starts a "shutdown" process which indirectly calls _call_eof_received().

So there are many ways to reach this line, and different reasons causing it.

Copy link
Contributor Author

@sileht sileht Jun 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we have other reasons of why the connection is being reset here.
ConnectionResetError here is only raised if the state of the connection is SSLProtocolState.DO_HANDSHAKE.

The _call_eof_received() method can be called only by _do_shutdown() and _do_read()

  • _do_shutdown() is only called if the state is SSLProtocolState.SHUTDOWN.
  • _do_read() is only called if the state is SSLProtocolState.WRAPPED.

So this exception can only be raised at the early stage of the SSL connection establishment.

@vstinner
Copy link
Member

Well, it seems like I'm not the right person to review this change. @pitrou @1st1: Would you mind to have a look at this asyncio enhancement?

@sileht
Copy link
Contributor Author

sileht commented Jun 29, 2022

@vstinner thanks!

@sileht
Copy link
Contributor Author

sileht commented Jul 20, 2022

@pitrou @1st1 can I get some insight, to get that in?

@gvanrossum
Copy link
Member

Won't fix, see issue.

@gvanrossum gvanrossum closed this Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

X Tutup