aws / amazon-redshift-python-driver

Redshift Python Connector. It supports Python Database API Specification v2.0.
Apache License 2.0
203 stars 75 forks source link

Raise OperationalError for socket timeouts #179

Closed jiezhen-chen closed 1 year ago

jiezhen-chen commented 1 year ago

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:

    raise OperationalError("connection time out", e)
redshift_connector.error.OperationalError: ('connection time out', TimeoutError(60, 'Operation timed out'))

Added unit test and integration test as well.

Screenshots (if appropriate)

Types of changes

Checklist

Brooke-white commented 1 year ago

@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