-
Notifications
You must be signed in to change notification settings - Fork 74
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
Raise OperationalError for socket timeouts #179
Conversation
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.
there's a few performance test files that have changes, could we revert those?
redshift_connector/core.py
Outdated
@@ -658,7 +658,10 @@ def get_calling_module() -> str: | |||
self._usock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) | |||
except socket.error as e: | |||
self._usock.close() | |||
raise InterfaceError("communication error", e) | |||
if socket.timeout: |
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.
this check needs to be reworked as socket.timeout
will always be true. maybe something like this?
except socket.error.timeout as timeout_e:
raise OperationalError("connection time out", timeout_e)
except socket.error as e:
raise InterfaceError("communication error", e)
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.
Hmm, I don't believe that's true. In manual testing, this error only comes up when I either disconnect my network, or when I set timeout = 0.
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.
You're right.... the evaluation of if socket.timeout
will always return true. I'm now using two except blocks instead as you suggested. Thank you!
546588c
to
d4e11c3
Compare
@jiezhen-chen -- testing looks good, no regressions. if you could run the repo pre-commit hooks on this change I will go ahead and merge it |
* Raise OperationalError for socket timeouts * add unit test and integrationt test * rectify unit test * rectify integration test for socket_timeout * remove empty config.ini
Map socket timeout errors to OperationalError instead of InterfaceError
Description
socket.timeouts are a subclass within socket.error, and socket.error is classified as InterfaceError. Hence socket.timeouts gets classified as InterfaceError as well. This change will map socket.timeouts alone to OperationalError, where other exceptions within socket.errors will remain unchanged.
Motivation and Context
This PR resolves this issue
Testing
Conducted manual testing - hit timeout and received the below error message:
Added unit test and integration test as well.
Screenshots (if appropriate)
Types of changes
Checklist
./build.sh
succeedspytest test/unit
and they are passing.