Skip to content
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

gh-118950: Fix SSLProtocol.connection_lost not being called when OSError is thrown on asyncio.write. #118960

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cjavad
Copy link

@cjavad cjavad commented May 12, 2024

Let _SSLProtocolTransport.is_closing reflect SSLProtocol internal transport closing state so that StreamWriter.drain will invoke sleep(0) which calls connection_lost and correctly notifies waiters of connection lost. (#118394)

In an existing comment in asyncio/streams.py there is some logic that correctly ensures that the connection_lost function is always called for users that keep writing and draining in some other context.

The issue here is that this code only runs when the transport is marked as closing, which in the case of the _SSLTransportProtocol only happened after connection_lost has been called.

My proposed fix is for _SSLTransportProtocol.is_closing to also return true when its inner transport is marked as closing, when connection_lost is called the inner transport is removed and instead the _closed flag is set.

No additional tests have been added (yet).

Copy link

cpython-cla-bot bot commented May 12, 2024

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app
Copy link

bedevere-app bot commented May 12, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

…ocol internal transport closing state so that StreamWriter.drain will invoke sleep(0) which calls connection_lost and correctly notifies waiters of connection lost. (python#118950)
@cjavad
Copy link
Author

cjavad commented May 12, 2024

As requested @gvanrossum i've opened up a PR for #118950

cjavad added a commit to SimplyPrint/printer-ws-client that referenced this pull request May 18, 2024
…e connection and cancellation and handle exceptions more gracefully. This addresses the 1006 issue.
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.

None yet

1 participant