[ https://issues.apache.org/jira/browse/THRIFT-5777?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
xuyundong updated THRIFT-5777: ------------------------------ Description: h2. What error occurred? When the Python client times out while reading content from the server, the exception thrown is not "read timeout," but rather "unexpected exception." h2. Why did this error occur? h3. the socket.timeout error doesn't includes the errno parameter in its args attribute. I try to make a timeout error on my pc, it only contains the error string. {code:java} Python 3.11.1 (main, Jan 5 2023, 14:25:08) [GCC 11.3.0] Type 'copyright', 'credits' or 'license' for more information IPython 8.13.2 – An enhanced Interactive Python. Type '?' for help.In [1]: import socket ...: from urllib.request import urlopen ...: ...: url = 'http://httpbin.org/get' ...: ...: socket.setdefaulttimeout(0.01) ...: try: ...: urlopen(url) ...: except Exception as e: ...: err1 = e.reason ...: ...:In [2]: type(err1) Out[2]: TimeoutErrorIn [3]: err1.args Out[3]: ('timed out',) {code} And my system is ubuntu 22.04 {code:java} ø> uname -a Linux Macmini 6.2.0-36-generic #37~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct 9 15:34:04 UTC 2 x86_64 x86_64 x86_64 GNU/Linux {code} *TSocket.read handle exception error* Because {code:java} socket.error.args == ('timed out',){code} , the condition {code:java} elif e.args[0] == errno.ETIMEDOUT{code} cannot be True, resulting in the throwing of the wrong exception {{{}TTransportException(message="unexpected exception", inner=e){}}}. h2. How to fix it I determine whether a timeout has occurred by checking if the exception is a socket.timeout, no longer relying on e.args. see details on PR: [https://github.com/apache/thrift/pull/2961] was: h2. What error occurred? When the Python client times out while reading content from the server, the exception thrown is not "read timeout," but rather "unexpected exception." h2. Why did this error occur? h3. the socket.timeout error doesn't includes the errno parameter in its args attribute. I try to make a timeout error on my pc, it only contains the error string. {code:java} Python 3.11.1 (main, Jan 5 2023, 14:25:08) [GCC 11.3.0] Type 'copyright', 'credits' or 'license' for more information IPython 8.13.2 – An enhanced Interactive Python. Type '?' for help.In [1]: import socket ...: from urllib.request import urlopen ...: ...: url = 'http://httpbin.org/get' ...: ...: socket.setdefaulttimeout(0.01) ...: try: ...: urlopen(url) ...: except Exception as e: ...: err1 = e.reason ...: ...:In [2]: type(err1) Out[2]: TimeoutErrorIn [3]: err1.args Out[3]: ('timed out',) {code} And my system is ubuntu 22.04 {code:java} ø> uname -a Linux Macmini 6.2.0-36-generic #37~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct 9 15:34:04 UTC 2 x86_64 x86_64 x86_64 GNU/Linux {code} *TSocket.read handle exception error* Because \{{}} {code:java} socket.error.args == ('timed out',){code} , the condition \{{}} {code:java} elif e.args[0] == errno.ETIMEDOUT{code} {{cannot be True, resulting in the throwing of the wrong exception }} {{{}TTransportException(message="unexpected exception", inner=e){}}}. h2. How to fix it I determine whether a timeout has occurred by checking if the exception is a socket.timeout, no longer relying on e.args. see details on PR: [https://github.com/apache/thrift/pull/2961] > timeout exception mismatched > ---------------------------- > > Key: THRIFT-5777 > URL: https://issues.apache.org/jira/browse/THRIFT-5777 > Project: Thrift > Issue Type: Bug > Components: Python - Library > Affects Versions: 0.18.1, 0.19.0, 0.20.0 > Reporter: xuyundong > Priority: Major > Fix For: 0.21.0 > > > h2. What error occurred? > When the Python client times out while reading content from the server, the > exception thrown is not "read timeout," but rather "unexpected exception." > h2. Why did this error occur? > h3. the socket.timeout error doesn't includes the errno parameter in its args > attribute. > I try to make a timeout error on my pc, it only contains the error string. > > {code:java} > Python 3.11.1 (main, Jan 5 2023, 14:25:08) [GCC 11.3.0] > Type 'copyright', 'credits' or 'license' for more information > IPython 8.13.2 – An enhanced Interactive Python. Type '?' for help.In [1]: > import socket > ...: from urllib.request import urlopen > ...: > ...: url = 'http://httpbin.org/get' > ...: > ...: socket.setdefaulttimeout(0.01) > ...: try: > ...: urlopen(url) > ...: except Exception as e: > ...: err1 = e.reason > ...: > ...:In [2]: type(err1) > Out[2]: TimeoutErrorIn [3]: err1.args > Out[3]: ('timed out',) > {code} > And my system is ubuntu 22.04 > {code:java} > ø> uname -a > Linux Macmini 6.2.0-36-generic #37~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct > 9 15:34:04 UTC 2 x86_64 x86_64 x86_64 GNU/Linux > {code} > *TSocket.read handle exception error* > Because > {code:java} > socket.error.args == ('timed out',){code} > , the condition > {code:java} > elif e.args[0] == errno.ETIMEDOUT{code} > > cannot be True, resulting in the throwing of the wrong exception > {{{}TTransportException(message="unexpected exception", inner=e){}}}. > h2. How to fix it > I determine whether a timeout has occurred by checking if the exception is a > socket.timeout, no longer relying on e.args. > see details on PR: [https://github.com/apache/thrift/pull/2961] -- This message was sent by Atlassian Jira (v8.20.10#820010)