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

fix: make timeouterror more compatible with future versions of Python #2991

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bwangelme
Copy link
Contributor

see reason in #2961

starting from python 3.10, this is a deprecated alias to TimeoutError: https://docs.python.org/3.12/library/socket.html#socket.timeout
while TimeoutError also exists in 3.8 (the earliest version of python still supported): https://docs.python.org/3.8/library/exceptions.html#TimeoutError
so I wonder if we should be more future proof and handle both socket.timeout and TimeoutError here, and then we can drop socket.timeout when 3.10 becomes the earliest version of python supported.

  • Did you create an Apache Jira ticket? (Request account here, not required for trivial changes)
  • If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
  • Did you squash your changes to a single commit? (not required, but preferred)
  • Did you do your best to avoid breaking changes? If one was needed, did you label the Jira ticket with "Breaking-Change"?
  • If your change does not involve any code, include [skip ci] anywhere in the commit message to free up build resources.

@@ -151,7 +151,8 @@ def open(self):
def read(self, sz):
try:
buff = self.handle.recv(sz)
except socket.timeout as e:
# TODO: remove socket.timeout when 3.10 becomes the earliest version of python supported.
except (socket.timeout, TimeoutError) as e:
raise TTransportException(type=TTransportException.TIMED_OUT, message="read timeout", inner=e)
except socket.error as e:
Copy link
Member

Choose a reason for hiding this comment

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

similarly socket.error is also going to be a deprecated alias to OSError so we probably want to do something similar here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants