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-93821: Handle connection resets on Windows #124779

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Klaar-pretzel
Copy link

@Klaar-pretzel Klaar-pretzel commented Sep 30, 2024

Refactor OSError re-throwing and wrap all instances of 'ov.getresult()' with the decorator so that client-side disconnects can be gracefully handled. Update the Proactor server to handle the connection and continue looping and serving (client disconnects are not a fatal error).

I discovered that, especially under heavy server load, the asycio Windows server could slow down and could end up throwing [WinError 64] The specified network name is no longer available errors. This occurs when clients connect and disconnect before the asyncio code has time to service the connection, especially if the client side disconnects erroneously (for example, if it's process was immediately killed before it could gracefully close the connection). These errors would bubble up into the proactor server loop and cause the socket there close - and never get re-opened. The result of this is that my servers would appear to hang, requiring a force-restart to restore their functionality.

The solution here catches all potential connection reset errors in the IocpProactor class by clients. It appears that the sending-side was previously capturing the errors, but likely the tight timing of the client connection sequence meant errors in these steps weren't noticed previously.

Refactor OSError re-throwing and wrap all instances of 'ov.getresult()'
with the decorator so that client-side disconnects can be gracefully
handled. Update the Proactor server to handle the connection and
continue looping and serving (client disconnects are not a fatal error).
Copy link

cpython-cla-bot bot commented Sep 30, 2024

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Sep 30, 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.

@Klaar-pretzel
Copy link
Author

Similar to this one #124032, however this is a little bit more complete by capturing more potential problems that were observed in the original patch.

@@ -0,0 +1 @@
Fix error handling in windows events where clients terminating connections could result in an asyncio server using Proactor event loops to hang indefinitely.

Choose a reason for hiding this comment

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

About NEWS format please to reading this: https://devguide.python.org/documentation/markup/
for example:

:mod:`asyncio`

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.

2 participants