-
-
Notifications
You must be signed in to change notification settings - Fork 30k
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
base: main
Are you sure you want to change the base?
Conversation
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).
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 |
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. |
There was a problem hiding this comment.
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`
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.