Issue 32729: socket.readinto() doesn't catch TimeoutError
Created on 2018-01-31 06:37 by rkdls, last changed 2022-04-11 14:58 by admin. This issue is now closed.
Messages (9)
msg311313 - (view)
Author: yang (rkdls) *
Date: 2018-01-31 06:37
Date: 2018-02-02 07:35
Date: 2018-02-03 09:08
Date: 2018-02-03 09:15
Date: 2018-07-11 14:25
socket error handling neededmsg311332 - (view) Author: yang (rkdls) * Date: 2018-01-31 14:21
If socket error occurred I think it is a timeout error or something. but It's not error raising correctly but IndexError which is not correct error MSG. It will be fixed or None type check needed.msg311333 - (view) Author: yang (rkdls) * Date: 2018-01-31 14:29
In the lib/socket.py Inside of readinto function, 576 line needed None type check or somethingmsg311483 - (view) Author: Inada Naoki (methane) *
Date: 2018-02-02 07:35
Please give us reproducible example. Otherwise, we can't know it's our bug or it's bug of caller.msg311541 - (view) Author: yang (rkdls) * Date: 2018-02-03 08:02
When timeout error occurred in urllib3.Poolmanager.urlopen(), the built-in TimeoutError raised which is not caught in existing timeout exception clause. Thus, It is caught by 'error' except and it is not checking Nonetype so that raising IndexError It patched that error and detailed in PR-5458 https://github.com/python/cpython/pull/5458 Thank you and sorry for not good at english.msg311542 - (view) Author: Inada Naoki (methane) *
Date: 2018-02-03 09:08
It may be bug of raising TimeoutError, not catching. That's why I want example code to reproduce.msg311543 - (view) Author: Inada Naoki (methane) *
Date: 2018-02-03 09:15
And your screenshot doesn't contain "full" traceback chain. It can be very important hint about who creates invalid TimeoutError.msg311545 - (view) Author: yang (rkdls) * Date: 2018-02-03 10:54
Oh.. you are right.
I think it's my bug. here is code
```
import urllib3
import certifi
from functools import wraps
import signal
from urllib3 import Timeout
def timeoutdec(sec):
def decorator(func):
def _timeout(signum, frame):
raise TimeoutError()
@wraps(func)
def wrapper(*args, **kwargs):
signal.signal(signal.SIGALRM, _timeout)
signal.alarm(sec)
try:
result = func(*args, **kwargs)
finally:
signal.alarm(0)
return result
return wrapper
return decorator
@timeoutdec(2)
def for_test():
timeout = Timeout(connect=10.0, read=2.0)
url = 'http://httpbin.org/delay/7'
method = 'GET'
body = None
headers = None
http = urllib3.PoolManager(timeout=timeout,
cert_reqs='CERT_REQUIRED',
ca_certs=certifi.where())
while True:
response = http.urlopen(method, url,
body=body,
headers=headers,
preload_content=True)
print(response.data)
for_test()
```
here is the code that i got same traceback.
maybe the TimeoutError is raised from my code, timeoutdec().
I thought it was python bug. sorry for bothering you.
and I will close my PR-32729.
msg321456 - (view)
Author: STINNER Victor (vstinner) *
Date: 2018-07-11 14:25
According to the reporter, it's not a bug in Python.
History
Date
User
Action
Args
2022-04-11 14:58:57adminsetgithub: 76910
2018-07-11 14:25:59vstinnersetstatus: open -> closed
versions: - Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8 2018-07-11 07:52:38serhiy.storchakasettype: crash -> behavior 2018-02-03 10:54:37rkdlssetmessages: + msg311545 2018-02-03 09:15:47methanesetmessages: + msg311543 2018-02-03 09:08:40methanesetmessages: + msg311542 2018-02-03 08:02:54rkdlssetmessages: + msg311541 2018-02-02 07:35:15methanesetnosy: + methane
messages: + msg311483
2018-01-31 14:29:38rkdlssetmessages: + msg311333 2018-01-31 14:27:42rkdlssetkeywords: + patch
stage: patch review
pull_requests: + pull_request5286 2018-01-31 14:21:35rkdlssetresolution: fixed
messages: + msg311332 2018-01-31 06:37:29rkdlscreate
nosy:
+ vstinner
messages:
+ msg321456
resolution: fixed -> not a bug
stage: patch review -> resolved
versions: - Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8 2018-07-11 07:52:38serhiy.storchakasettype: crash -> behavior 2018-02-03 10:54:37rkdlssetmessages: + msg311545 2018-02-03 09:15:47methanesetmessages: + msg311543 2018-02-03 09:08:40methanesetmessages: + msg311542 2018-02-03 08:02:54rkdlssetmessages: + msg311541 2018-02-02 07:35:15methanesetnosy: + methane
messages: + msg311483
2018-01-31 14:29:38rkdlssetmessages: + msg311333 2018-01-31 14:27:42rkdlssetkeywords: + patch
stage: patch review
pull_requests: + pull_request5286 2018-01-31 14:21:35rkdlssetresolution: fixed
messages: + msg311332 2018-01-31 06:37:29rkdlscreate