-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
PYTHON-5014 Fix handling of async socket errors in kms request #2054
Conversation
pymongo/asynchronous/encryption.py
Outdated
@@ -213,6 +213,9 @@ async def kms_request(self, kms_context: MongoCryptKmsContext) -> None: | |||
if not data: | |||
raise OSError("KMS connection closed") | |||
kms_context.feed(data) | |||
# Async raises an OSError instead of returning empty bytes | |||
except OSError as err: | |||
raise OSError("KMS connection closed") from err |
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.
Doesn't OSError already get handled by the except Exception as exc
block? It should hit the _raise_connection_failure line which adds important info to the error message like the host/port/connection timeouts.
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.
Fixed
I wonder if some of this logic can be removed after the async streams/protocol work is merged? |
This addresses the MacOS encryption errors but not yet the Encryption PyOpenSSL errors.
It addresses the Encryption PyOpenSSL error by expanding the regex to include "SSL handshake failed".