Skip to content
Myr

Catch and wrap ClosedPoolError

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Partially resolves #1572: "urllib3 exceptions passing through requests API". Inspired from Lukasa's 2605be11d82d42438ac7c3993810c955bde74cef.

authored by Susan Tan · committed by Susan Tan · parent 0be38a0 · Browse files · 2 files+14 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+14 added−0 removed

  • other:+14 added−0 removed

2 files+14 added−0 removed

modified:requests/adapters.py+4 added
17 unmodified lines
18from .compat import urlparse, basestring19from .utils import (DEFAULT_CA_BUNDLE_PATH, get_encoding_from_headers,20 prepend_scheme_if_needed, get_auth_from_url, urldefragauth)21from .structures import CaseInsensitiveDict22from .packages.urllib3.exceptions import ClosedPoolError23from .packages.urllib3.exceptions import ConnectTimeoutError24from .packages.urllib3.exceptions import HTTPError as _HTTPError25from .packages.urllib3.exceptions import MaxRetryError26from .packages.urllib3.exceptions import ProxyError as _ProxyError
394 unmodified lines
421 raise RetryError(e, request=request)422423 raise ConnectionError(e, request=request)424425 except ClosedPoolError as e:426 raise ConnectionError(e, request=request)427428 except _ProxyError as e:429 raise ProxyError(e)430431 except (_SSLError, _HTTPError) as e:
8 unmodified lines
modified:test_requests.py+10 added
1653 unmodified lines
16541655 with pytest.raises(RetryError):1656 s.get(httpbin('status/500'))165716581659def test_urllib3_pool_connection_closed():1660 s = requests.Session()1661 s.mount('http://', HTTPAdapter(pool_connections=0, pool_maxsize=0))16621663 try:1664 s.get(httpbin('status/200'))1665 except ConnectionError as e:1666 assert u"HTTPConnectionPool(host='httpbin.org', port=80): Pool is closed." in str(e.message)16671668def test_vendor_aliases():1669 from requests.packages import urllib31670 from requests.packages import chardet1671
5 unmodified lines