question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

A socket timeout exception in Python 3 shows also a TypeError

See original GitHub issue

When a timout occurs it also shows the TypeError because you first try to call it with a buffering keyword argument, which does not exist in Python 3. I’m not sure if there is a good way in Python 3 to clear that TypeError exception. See also #537.

ERROR: Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 331, in _make_request
    httplib_response = conn.getresponse(buffering=True)
TypeError: getresponse() got an unexpected keyword argument 'buffering'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 333, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.4/http/client.py", line 1172, in getresponse
    response.begin()
  File "/usr/lib/python3.4/http/client.py", line 351, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.4/http/client.py", line 313, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.4/socket.py", line 371, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.4/ssl.py", line 745, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.4/ssl.py", line 617, in read
    v = self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 362, in send
    timeout=timeout
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 559, in urlopen
    _pool=self, _stacktrace=stacktrace)
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 245, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/lib/python3/dist-packages/six.py", line 625, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 516, in urlopen
    body=body, headers=headers)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 336, in _make_request
    self, url, "Read timed out. (read timeout=%s)" % read_timeout)
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='commons.wikimedia.org', port=443): Read timed out. (read timeout=30)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/matanya/core/pywikibot/data/api.py", line 1911, in submit
    body=body, headers=headers)
  File "/home/matanya/core/pywikibot/tools/__init__.py", line 1227, in wrapper
    return obj(*__args, **__kw)
  File "/home/matanya/core/pywikibot/comms/http.py", line 240, in request
    r = fetch(baseuri, method, body, headers, **kwargs)
  File "/home/matanya/core/pywikibot/comms/http.py", line 359, in fetch
    error_handling_callback(request)
  File "/home/matanya/core/pywikibot/comms/http.py", line 276, in error_handling_callback
    raise request.data
  File "/home/matanya/core/pywikibot/comms/http.py", line 255, in _http_process
    auth=auth, timeout=timeout, verify=True)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 457, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 569, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 422, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='commons.wikimedia.org', port=443): Read timed out. (read timeout=30)

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Lukasacommented, Jul 21, 2015

Yeah, this is a known issue that causes lots of bug reports on Requests. There is no way to do anything about this, though: the CPython developers believe this is a feature, not a bug.

0reactions
jayvdbcommented, May 14, 2016

This was fixed in #861

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python 3.5.2: socket.timeout exception causes typeerror
It's caused by trying to use timingout to catch an exception. timingout is an integer object whereas the except statement only accepts ...
Read more >
Built-in Exceptions — Python 3.11.1 documentation
A subclass of ConnectionError , raised when a connection attempt is aborted by the peer. Corresponds to errno ECONNABORTED . exception ConnectionRefusedError ...
Read more >
18.1. socket — Low-level networking interface - Read the Docs
A subclass of OSError , this exception is raised when a timeout occurs on a socket which has had timeouts enabled via a...
Read more >
Netmiko4 read_timeout - Python for Network Engineers
In Netmiko 3.4.0 'send_command()' will search through the device's ... and it raises an exception (in this case a ReadTimeout exception).
Read more >
python-eventlet fails to build with Python 3.10: TypeError: can't ...
3.1 Configuration error: There is a programmable error in your configuration file: Traceback (most recent call last): File "/usr/lib/python3.10/ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found