self = <tests.test_requests.TestTimeout object at 0x7f5e368d9ae0>, timeout = (0.1, None) #x1B[37m@pytest#x1B[39;49;00m.mark.parametrize( #x1B[33m"#x1B[39;49;00m#x1B[33mtimeout#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, ((#x1B[94m0.1#x1B[39;49;00m, #x1B[94mNone#x1B[39;49;00m), Urllib3Timeout(connect=#x1B[94m0.1#x1B[39;49;00m, read=#x1B[94mNone#x1B[39;49;00m)) ) #x1B[94mdef#x1B[39;49;00m #x1B[92mtest_connect_timeout#x1B[39;49;00m(#x1B[96mself#x1B[39;49;00m, timeout): #x1B[94mtry#x1B[39;49;00m: requests.get(TARPIT, timeout=timeout) > pytest.fail(#x1B[33m"#x1B[39;49;00m#x1B[33mThe connect() request should time out.#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m) #x1B[1m#x1B[31mE Failed: The connect() request should time out.#x1B[0m #x1B[1m#x1B[31mtests/test_requests.py#x1B[0m:2434: Failedself = <tests.test_requests.TestTimeout object at 0x7f5e36a624d0>, timeout = Timeout(connect=0.1, read=None, total=None) #x1B[37m@pytest#x1B[39;49;00m.mark.parametrize( #x1B[33m"#x1B[39;49;00m#x1B[33mtimeout#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, ((#x1B[94m0.1#x1B[39;49;00m, #x1B[94mNone#x1B[39;49;00m), Urllib3Timeout(connect=#x1B[94m0.1#x1B[39;49;00m, read=#x1B[94mNone#x1B[39;49;00m)) ) #x1B[94mdef#x1B[39;49;00m #x1B[92mtest_connect_timeout#x1B[39;49;00m(#x1B[96mself#x1B[39;49;00m, timeout): #x1B[94mtry#x1B[39;49;00m: requests.get(TARPIT, timeout=timeout) > pytest.fail(#x1B[33m"#x1B[39;49;00m#x1B[33mThe connect() request should time out.#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m) #x1B[1m#x1B[31mE Failed: The connect() request should time out.#x1B[0m #x1B[1m#x1B[31mtests/test_requests.py#x1B[0m:2434: Failedself = <urllib3.connectionpool.HTTPConnectionPool object at 0x7f5e369faad0> conn = <urllib3.connection.HTTPConnection object at 0x7f5e369f8490>, method = 'GET', url = '/' timeout = Timeout(connect=0.1, read=0.1, total=None), chunked = False httplib_request_kw = {'body': None, 'headers': {'User-Agent': 'python-requests/2.28.0', 'Accept-Encoding': 'gzip, deflate, br', 'Accept': '*/*', 'Connection': 'keep-alive'}} timeout_obj = Timeout(connect=0.1, read=0.1, total=None), read_timeout = 0.1 #x1B[94mdef#x1B[39;49;00m #x1B[92m_make_request#x1B[39;49;00m( #x1B[96mself#x1B[39;49;00m, conn, method, url, timeout=_Default, chunked=#x1B[94mFalse#x1B[39;49;00m, **httplib_request_kw ): #x1B[33m"""#x1B[39;49;00m #x1B[33m Perform a request on a given urllib connection object taken from our#x1B[39;49;00m #x1B[33m pool.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param conn:#x1B[39;49;00m #x1B[33m a connection from one of our connection pools#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param timeout:#x1B[39;49;00m #x1B[33m Socket timeout in seconds for the request. This can be a#x1B[39;49;00m #x1B[33m float or integer, which will set the same timeout value for#x1B[39;49;00m #x1B[33m the socket connect and the socket read, or an instance of#x1B[39;49;00m #x1B[33m :class:`urllib3.util.Timeout`, which gives you more fine-grained#x1B[39;49;00m #x1B[33m control over your timeouts.#x1B[39;49;00m #x1B[33m """#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.num_requests += #x1B[94m1#x1B[39;49;00m timeout_obj = #x1B[96mself#x1B[39;49;00m._get_timeout(timeout) timeout_obj.start_connect() conn.timeout = timeout_obj.connect_timeout #x1B[90m# Trigger any extra validation we need to do.#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: #x1B[96mself#x1B[39;49;00m._validate_conn(conn) #x1B[94mexcept#x1B[39;49;00m (SocketTimeout, BaseSSLError) #x1B[94mas#x1B[39;49;00m e: #x1B[90m# Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout.#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m._raise_timeout(err=e, url=url, timeout_value=conn.timeout) #x1B[94mraise#x1B[39;49;00m #x1B[90m# conn.request() calls http.client.*.request, not the method in#x1B[39;49;00m #x1B[90m# urllib3.request. It also calls makefile (recv) on the socket.#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: #x1B[94mif#x1B[39;49;00m chunked: conn.request_chunked(method, url, **httplib_request_kw) #x1B[94melse#x1B[39;49;00m: conn.request(method, url, **httplib_request_kw) #x1B[90m# We are swallowing BrokenPipeError (errno.EPIPE) since the server is#x1B[39;49;00m #x1B[90m# legitimately able to close the connection after sending a valid response.#x1B[39;49;00m #x1B[90m# With this behaviour, the received response is still readable.#x1B[39;49;00m #x1B[94mexcept#x1B[39;49;00m #x1B[96mBrokenPipeError#x1B[39;49;00m: #x1B[90m# Python 3#x1B[39;49;00m #x1B[94mpass#x1B[39;49;00m #x1B[94mexcept#x1B[39;49;00m #x1B[96mIOError#x1B[39;49;00m #x1B[94mas#x1B[39;49;00m e: #x1B[90m# Python 2 and macOS/Linux#x1B[39;49;00m #x1B[90m# EPIPE and ESHUTDOWN are BrokenPipeError on Python 2, and EPROTOTYPE is needed on macOS#x1B[39;49;00m #x1B[90m# https://erickt.github.io/blog/2014/11/19/adventures-in-debugging-a-potential-osx-kernel-bug/#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m e.errno #x1B[95mnot#x1B[39;49;00m #x1B[95min#x1B[39;49;00m { errno.EPIPE, errno.ESHUTDOWN, errno.EPROTOTYPE, }: #x1B[94mraise#x1B[39;49;00m #x1B[90m# Reset the timeout for the recv() on the socket#x1B[39;49;00m read_timeout = timeout_obj.read_timeout #x1B[90m# App Engine doesn't have a sock attr#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m #x1B[96mgetattr#x1B[39;49;00m(conn, #x1B[33m"#x1B[39;49;00m#x1B[33msock#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[94mNone#x1B[39;49;00m): #x1B[90m# In Python 3 socket.py will catch EAGAIN and return None when you#x1B[39;49;00m #x1B[90m# try and read into the file pointer created by http.client, which#x1B[39;49;00m #x1B[90m# instead raises a BadStatusLine exception. Instead of catching#x1B[39;49;00m #x1B[90m# the exception and assuming all BadStatusLine exceptions are read#x1B[39;49;00m #x1B[90m# timeouts, check for a zero timeout before making the request.#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m read_timeout == #x1B[94m0#x1B[39;49;00m: #x1B[94mraise#x1B[39;49;00m ReadTimeoutError( #x1B[96mself#x1B[39;49;00m, url, #x1B[33m"#x1B[39;49;00m#x1B[33mRead timed out. (read timeout=#x1B[39;49;00m#x1B[33m%s#x1B[39;49;00m#x1B[33m)#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m % read_timeout ) #x1B[94mif#x1B[39;49;00m read_timeout #x1B[95mis#x1B[39;49;00m Timeout.DEFAULT_TIMEOUT: conn.sock.settimeout(socket.getdefaulttimeout()) #x1B[94melse#x1B[39;49;00m: #x1B[90m# None or a value#x1B[39;49;00m conn.sock.settimeout(read_timeout) #x1B[90m# Receive the response from the server#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: #x1B[94mtry#x1B[39;49;00m: #x1B[90m# Python 2.7, use buffering of HTTP responses#x1B[39;49;00m httplib_response = conn.getresponse(buffering=#x1B[94mTrue#x1B[39;49;00m) #x1B[94mexcept#x1B[39;49;00m #x1B[96mTypeError#x1B[39;49;00m: #x1B[90m# Python 3#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: httplib_response = conn.getresponse() #x1B[94mexcept#x1B[39;49;00m #x1B[96mBaseException#x1B[39;49;00m #x1B[94mas#x1B[39;49;00m e: #x1B[90m# Remove the TypeError from the exception chain in#x1B[39;49;00m #x1B[90m# Python 3 (including for exceptions like SystemExit).#x1B[39;49;00m #x1B[90m# Otherwise it looks like a bug in the code.#x1B[39;49;00m > six.raise_from(e, #x1B[94mNone#x1B[39;49;00m) #x1B[1m#x1B[31m/usr/lib/python3/dist-packages/urllib3/connectionpool.py#x1B[0m:449: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ value = None, from_value = None > #x1B[04m#x1B[91m?#x1B[39;49;00m#x1B[04m#x1B[91m?#x1B[39;49;00m#x1B[04m#x1B[91m?#x1B[39;49;00m #x1B[1m#x1B[31m<string>#x1B[0m:3: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <urllib3.connectionpool.HTTPConnectionPool object at 0x7f5e369faad0> conn = <urllib3.connection.HTTPConnection object at 0x7f5e369f8490>, method = 'GET', url = '/' timeout = Timeout(connect=0.1, read=0.1, total=None), chunked = False httplib_request_kw = {'body': None, 'headers': {'User-Agent': 'python-requests/2.28.0', 'Accept-Encoding': 'gzip, deflate, br', 'Accept': '*/*', 'Connection': 'keep-alive'}} timeout_obj = Timeout(connect=0.1, read=0.1, total=None), read_timeout = 0.1 #x1B[94mdef#x1B[39;49;00m #x1B[92m_make_request#x1B[39;49;00m( #x1B[96mself#x1B[39;49;00m, conn, method, url, timeout=_Default, chunked=#x1B[94mFalse#x1B[39;49;00m, **httplib_request_kw ): #x1B[33m"""#x1B[39;49;00m #x1B[33m Perform a request on a given urllib connection object taken from our#x1B[39;49;00m #x1B[33m pool.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param conn:#x1B[39;49;00m #x1B[33m a connection from one of our connection pools#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param timeout:#x1B[39;49;00m #x1B[33m Socket timeout in seconds for the request. This can be a#x1B[39;49;00m #x1B[33m float or integer, which will set the same timeout value for#x1B[39;49;00m #x1B[33m the socket connect and the socket read, or an instance of#x1B[39;49;00m #x1B[33m :class:`urllib3.util.Timeout`, which gives you more fine-grained#x1B[39;49;00m #x1B[33m control over your timeouts.#x1B[39;49;00m #x1B[33m """#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.num_requests += #x1B[94m1#x1B[39;49;00m timeout_obj = #x1B[96mself#x1B[39;49;00m._get_timeout(timeout) timeout_obj.start_connect() conn.timeout = timeout_obj.connect_timeout #x1B[90m# Trigger any extra validation we need to do.#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: #x1B[96mself#x1B[39;49;00m._validate_conn(conn) #x1B[94mexcept#x1B[39;49;00m (SocketTimeout, BaseSSLError) #x1B[94mas#x1B[39;49;00m e: #x1B[90m# Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout.#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m._raise_timeout(err=e, url=url, timeout_value=conn.timeout) #x1B[94mraise#x1B[39;49;00m #x1B[90m# conn.request() calls http.client.*.request, not the method in#x1B[39;49;00m #x1B[90m# urllib3.request. It also calls makefile (recv) on the socket.#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: #x1B[94mif#x1B[39;49;00m chunked: conn.request_chunked(method, url, **httplib_request_kw) #x1B[94melse#x1B[39;49;00m: conn.request(method, url, **httplib_request_kw) #x1B[90m# We are swallowing BrokenPipeError (errno.EPIPE) since the server is#x1B[39;49;00m #x1B[90m# legitimately able to close the connection after sending a valid response.#x1B[39;49;00m #x1B[90m# With this behaviour, the received response is still readable.#x1B[39;49;00m #x1B[94mexcept#x1B[39;49;00m #x1B[96mBrokenPipeError#x1B[39;49;00m: #x1B[90m# Python 3#x1B[39;49;00m #x1B[94mpass#x1B[39;49;00m #x1B[94mexcept#x1B[39;49;00m #x1B[96mIOError#x1B[39;49;00m #x1B[94mas#x1B[39;49;00m e: #x1B[90m# Python 2 and macOS/Linux#x1B[39;49;00m #x1B[90m# EPIPE and ESHUTDOWN are BrokenPipeError on Python 2, and EPROTOTYPE is needed on macOS#x1B[39;49;00m #x1B[90m# https://erickt.github.io/blog/2014/11/19/adventures-in-debugging-a-potential-osx-kernel-bug/#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m e.errno #x1B[95mnot#x1B[39;49;00m #x1B[95min#x1B[39;49;00m { errno.EPIPE, errno.ESHUTDOWN, errno.EPROTOTYPE, }: #x1B[94mraise#x1B[39;49;00m #x1B[90m# Reset the timeout for the recv() on the socket#x1B[39;49;00m read_timeout = timeout_obj.read_timeout #x1B[90m# App Engine doesn't have a sock attr#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m #x1B[96mgetattr#x1B[39;49;00m(conn, #x1B[33m"#x1B[39;49;00m#x1B[33msock#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[94mNone#x1B[39;49;00m): #x1B[90m# In Python 3 socket.py will catch EAGAIN and return None when you#x1B[39;49;00m #x1B[90m# try and read into the file pointer created by http.client, which#x1B[39;49;00m #x1B[90m# instead raises a BadStatusLine exception. Instead of catching#x1B[39;49;00m #x1B[90m# the exception and assuming all BadStatusLine exceptions are read#x1B[39;49;00m #x1B[90m# timeouts, check for a zero timeout before making the request.#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m read_timeout == #x1B[94m0#x1B[39;49;00m: #x1B[94mraise#x1B[39;49;00m ReadTimeoutError( #x1B[96mself#x1B[39;49;00m, url, #x1B[33m"#x1B[39;49;00m#x1B[33mRead timed out. (read timeout=#x1B[39;49;00m#x1B[33m%s#x1B[39;49;00m#x1B[33m)#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m % read_timeout ) #x1B[94mif#x1B[39;49;00m read_timeout #x1B[95mis#x1B[39;49;00m Timeout.DEFAULT_TIMEOUT: conn.sock.settimeout(socket.getdefaulttimeout()) #x1B[94melse#x1B[39;49;00m: #x1B[90m# None or a value#x1B[39;49;00m conn.sock.settimeout(read_timeout) #x1B[90m# Receive the response from the server#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: #x1B[94mtry#x1B[39;49;00m: #x1B[90m# Python 2.7, use buffering of HTTP responses#x1B[39;49;00m httplib_response = conn.getresponse(buffering=#x1B[94mTrue#x1B[39;49;00m) #x1B[94mexcept#x1B[39;49;00m #x1B[96mTypeError#x1B[39;49;00m: #x1B[90m# Python 3#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: > httplib_response = conn.getresponse() #x1B[1m#x1B[31m/usr/lib/python3/dist-packages/urllib3/connectionpool.py#x1B[0m:444: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <urllib3.connection.HTTPConnection object at 0x7f5e369f8490> #x1B[94mdef#x1B[39;49;00m #x1B[92mgetresponse#x1B[39;49;00m(#x1B[96mself#x1B[39;49;00m): #x1B[33m"""Get the response from the server.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m If the HTTPConnection is in the correct state, returns an#x1B[39;49;00m #x1B[33m instance of HTTPResponse or of whatever object is returned by#x1B[39;49;00m #x1B[33m the response_class variable.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m If a request has not been sent or if a previous response has#x1B[39;49;00m #x1B[33m not be handled, ResponseNotReady is raised. If the HTTP#x1B[39;49;00m #x1B[33m response indicates that the connection should be closed, then#x1B[39;49;00m #x1B[33m it will be closed before the response is returned. When the#x1B[39;49;00m #x1B[33m connection is closed, the underlying socket is closed.#x1B[39;49;00m #x1B[33m """#x1B[39;49;00m #x1B[90m# if a prior response has been completed, then forget about it.#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.__response #x1B[95mand#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.__response.isclosed(): #x1B[96mself#x1B[39;49;00m.__response = #x1B[94mNone#x1B[39;49;00m #x1B[90m# if a prior response exists, then it must be completed (otherwise, we#x1B[39;49;00m #x1B[90m# cannot read this response's header to determine the connection-close#x1B[39;49;00m #x1B[90m# behavior)#x1B[39;49;00m #x1B[90m##x1B[39;49;00m #x1B[90m# note: if a prior response existed, but was connection-close, then the#x1B[39;49;00m #x1B[90m# socket and response were made independent of this HTTPConnection#x1B[39;49;00m #x1B[90m# object since a new request requires that we open a whole new#x1B[39;49;00m #x1B[90m# connection#x1B[39;49;00m #x1B[90m##x1B[39;49;00m #x1B[90m# this means the prior response had one of two states:#x1B[39;49;00m #x1B[90m# 1) will_close: this connection was reset and the prior socket and#x1B[39;49;00m #x1B[90m# response operate independently#x1B[39;49;00m #x1B[90m# 2) persistent: the response was retained and we await its#x1B[39;49;00m #x1B[90m# isclosed() status to become true.#x1B[39;49;00m #x1B[90m##x1B[39;49;00m #x1B[94mif#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.__state != _CS_REQ_SENT #x1B[95mor#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.__response: #x1B[94mraise#x1B[39;49;00m ResponseNotReady(#x1B[96mself#x1B[39;49;00m.__state) #x1B[94mif#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.debuglevel > #x1B[94m0#x1B[39;49;00m: response = #x1B[96mself#x1B[39;49;00m.response_class(#x1B[96mself#x1B[39;49;00m.sock, #x1B[96mself#x1B[39;49;00m.debuglevel, method=#x1B[96mself#x1B[39;49;00m._method) #x1B[94melse#x1B[39;49;00m: response = #x1B[96mself#x1B[39;49;00m.response_class(#x1B[96mself#x1B[39;49;00m.sock, method=#x1B[96mself#x1B[39;49;00m._method) #x1B[94mtry#x1B[39;49;00m: #x1B[94mtry#x1B[39;49;00m: > response.begin() #x1B[1m#x1B[31m/usr/lib/python3.10/http/client.py#x1B[0m:1374: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <http.client.HTTPResponse object at 0x7f5e369f8790> #x1B[94mdef#x1B[39;49;00m #x1B[92mbegin#x1B[39;49;00m(#x1B[96mself#x1B[39;49;00m): #x1B[94mif#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.headers #x1B[95mis#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m: #x1B[90m# we've already started reading the response#x1B[39;49;00m #x1B[94mreturn#x1B[39;49;00m #x1B[90m# read until we get a non-100 response#x1B[39;49;00m #x1B[94mwhile#x1B[39;49;00m #x1B[94mTrue#x1B[39;49;00m: > version, status, reason = #x1B[96mself#x1B[39;49;00m._read_status() #x1B[1m#x1B[31m/usr/lib/python3.10/http/client.py#x1B[0m:318: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <http.client.HTTPResponse object at 0x7f5e369f8790> #x1B[94mdef#x1B[39;49;00m #x1B[92m_read_status#x1B[39;49;00m(#x1B[96mself#x1B[39;49;00m): > line = #x1B[96mstr#x1B[39;49;00m(#x1B[96mself#x1B[39;49;00m.fp.readline(_MAXLINE + #x1B[94m1#x1B[39;49;00m), #x1B[33m"#x1B[39;49;00m#x1B[33miso-8859-1#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m) #x1B[1m#x1B[31m/usr/lib/python3.10/http/client.py#x1B[0m:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <socket.SocketIO object at 0x7f5e369f8d00>, b = <memory at 0x7f5e35f0a2c0> #x1B[94mdef#x1B[39;49;00m #x1B[92mreadinto#x1B[39;49;00m(#x1B[96mself#x1B[39;49;00m, b): #x1B[33m"""Read up to len(b) bytes into the writable buffer *b* and return#x1B[39;49;00m #x1B[33m the number of bytes read. If the socket is non-blocking and no bytes#x1B[39;49;00m #x1B[33m are available, None is returned.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m If *b* is non-empty, a 0 return value indicates that the connection#x1B[39;49;00m #x1B[33m was shutdown at the other end.#x1B[39;49;00m #x1B[33m """#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m._checkClosed() #x1B[96mself#x1B[39;49;00m._checkReadable() #x1B[94mif#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m._timeout_occurred: #x1B[94mraise#x1B[39;49;00m #x1B[96mOSError#x1B[39;49;00m(#x1B[33m"#x1B[39;49;00m#x1B[33mcannot read from timed out object#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m) #x1B[94mwhile#x1B[39;49;00m #x1B[94mTrue#x1B[39;49;00m: #x1B[94mtry#x1B[39;49;00m: > #x1B[94mreturn#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m._sock.recv_into(b) #x1B[1m#x1B[31mE TimeoutError: timed out#x1B[0m #x1B[1m#x1B[31m/usr/lib/python3.10/socket.py#x1B[0m:705: TimeoutError #x1B[33mDuring handling of the above exception, another exception occurred:#x1B[0m self = <requests.adapters.HTTPAdapter object at 0x7f5e369fbc70>, request = <PreparedRequest [GET]>, stream = False timeout = Timeout(connect=0.1, read=0.1, total=None), verify = True, cert = None, proxies = OrderedDict() #x1B[94mdef#x1B[39;49;00m #x1B[92msend#x1B[39;49;00m( #x1B[96mself#x1B[39;49;00m, request, stream=#x1B[94mFalse#x1B[39;49;00m, timeout=#x1B[94mNone#x1B[39;49;00m, verify=#x1B[94mTrue#x1B[39;49;00m, cert=#x1B[94mNone#x1B[39;49;00m, proxies=#x1B[94mNone#x1B[39;49;00m ): #x1B[33m"""Sends PreparedRequest object. Returns Response object.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param request: The :class:`PreparedRequest <PreparedRequest>` being sent.#x1B[39;49;00m #x1B[33m :param stream: (optional) Whether to stream the request content.#x1B[39;49;00m #x1B[33m :param timeout: (optional) How long to wait for the server to send#x1B[39;49;00m #x1B[33m data before giving up, as a float, or a :ref:`(connect timeout,#x1B[39;49;00m #x1B[33m read timeout) <timeouts>` tuple.#x1B[39;49;00m #x1B[33m :type timeout: float or tuple or urllib3 Timeout object#x1B[39;49;00m #x1B[33m :param verify: (optional) Either a boolean, in which case it controls whether#x1B[39;49;00m #x1B[33m we verify the server's TLS certificate, or a string, in which case it#x1B[39;49;00m #x1B[33m must be a path to a CA bundle to use#x1B[39;49;00m #x1B[33m :param cert: (optional) Any user-provided SSL certificate to be trusted.#x1B[39;49;00m #x1B[33m :param proxies: (optional) The proxies dictionary to apply to the request.#x1B[39;49;00m #x1B[33m :rtype: requests.Response#x1B[39;49;00m #x1B[33m """#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: conn = #x1B[96mself#x1B[39;49;00m.get_connection(request.url, proxies) #x1B[94mexcept#x1B[39;49;00m LocationValueError #x1B[94mas#x1B[39;49;00m e: #x1B[94mraise#x1B[39;49;00m InvalidURL(e, request=request) #x1B[96mself#x1B[39;49;00m.cert_verify(conn, request.url, verify, cert) url = #x1B[96mself#x1B[39;49;00m.request_url(request, proxies) #x1B[96mself#x1B[39;49;00m.add_headers( request, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies, ) chunked = #x1B[95mnot#x1B[39;49;00m (request.body #x1B[95mis#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m #x1B[95mor#x1B[39;49;00m #x1B[33m"#x1B[39;49;00m#x1B[33mContent-Length#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[95min#x1B[39;49;00m request.headers) #x1B[94mif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(timeout, #x1B[96mtuple#x1B[39;49;00m): #x1B[94mtry#x1B[39;49;00m: connect, read = timeout timeout = TimeoutSauce(connect=connect, read=read) #x1B[94mexcept#x1B[39;49;00m #x1B[96mValueError#x1B[39;49;00m: #x1B[94mraise#x1B[39;49;00m #x1B[96mValueError#x1B[39;49;00m( #x1B[33mf#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33mInvalid timeout #x1B[39;49;00m#x1B[33m{#x1B[39;49;00mtimeout#x1B[33m}#x1B[39;49;00m#x1B[33m. Pass a (connect, read) timeout tuple, #x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[33mf#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33mor a single float to set both timeouts to the same value.#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m ) #x1B[94melif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(timeout, TimeoutSauce): #x1B[94mpass#x1B[39;49;00m #x1B[94melse#x1B[39;49;00m: timeout = TimeoutSauce(connect=timeout, read=timeout) #x1B[94mtry#x1B[39;49;00m: #x1B[94mif#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m chunked: > resp = conn.urlopen( method=request.method, url=url, body=request.body, headers=request.headers, redirect=#x1B[94mFalse#x1B[39;49;00m, assert_same_host=#x1B[94mFalse#x1B[39;49;00m, preload_content=#x1B[94mFalse#x1B[39;49;00m, decode_content=#x1B[94mFalse#x1B[39;49;00m, retries=#x1B[96mself#x1B[39;49;00m.max_retries, timeout=timeout, ) #x1B[1m#x1B[31mrequests/adapters.py#x1B[0m:489: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <urllib3.connectionpool.HTTPConnectionPool object at 0x7f5e369faad0>, method = 'GET', url = '/', body = None headers = {'User-Agent': 'python-requests/2.28.0', 'Accept-Encoding': 'gzip, deflate, br', 'Accept': '*/*', 'Connection': 'keep-alive'} retries = Retry(total=0, connect=None, read=False, redirect=None, status=None), redirect = False, assert_same_host = False timeout = Timeout(connect=0.1, read=0.1, total=None), pool_timeout = None, release_conn = False, chunked = False body_pos = None, response_kw = {'decode_content': False, 'preload_content': False} parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/', query=None, fragment=None) destination_scheme = None, conn = None, release_this_conn = True, http_tunnel_required = False, err = None clean_exit = False #x1B[94mdef#x1B[39;49;00m #x1B[92murlopen#x1B[39;49;00m( #x1B[96mself#x1B[39;49;00m, method, url, body=#x1B[94mNone#x1B[39;49;00m, headers=#x1B[94mNone#x1B[39;49;00m, retries=#x1B[94mNone#x1B[39;49;00m, redirect=#x1B[94mTrue#x1B[39;49;00m, assert_same_host=#x1B[94mTrue#x1B[39;49;00m, timeout=_Default, pool_timeout=#x1B[94mNone#x1B[39;49;00m, release_conn=#x1B[94mNone#x1B[39;49;00m, chunked=#x1B[94mFalse#x1B[39;49;00m, body_pos=#x1B[94mNone#x1B[39;49;00m, **response_kw ): #x1B[33m"""#x1B[39;49;00m #x1B[33m Get a connection from the pool and perform an HTTP request. This is the#x1B[39;49;00m #x1B[33m lowest level call for making a request, so you'll need to specify all#x1B[39;49;00m #x1B[33m the raw details.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m .. note::#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m More commonly, it's appropriate to use a convenience method provided#x1B[39;49;00m #x1B[33m by :class:`.RequestMethods`, such as :meth:`request`.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m .. note::#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m `release_conn` will only behave as expected if#x1B[39;49;00m #x1B[33m `preload_content=False` because we want to make#x1B[39;49;00m #x1B[33m `preload_content=False` the default behaviour someday soon without#x1B[39;49;00m #x1B[33m breaking backwards compatibility.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param method:#x1B[39;49;00m #x1B[33m HTTP request method (such as GET, POST, PUT, etc.)#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param url:#x1B[39;49;00m #x1B[33m The URL to perform the request on.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param body:#x1B[39;49;00m #x1B[33m Data to send in the request body, either :class:`str`, :class:`bytes`,#x1B[39;49;00m #x1B[33m an iterable of :class:`str`/:class:`bytes`, or a file-like object.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param headers:#x1B[39;49;00m #x1B[33m Dictionary of custom headers to send, such as User-Agent,#x1B[39;49;00m #x1B[33m If-None-Match, etc. If None, pool headers are used. If provided,#x1B[39;49;00m #x1B[33m these headers completely replace any pool-specific headers.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param retries:#x1B[39;49;00m #x1B[33m Configure the number of retries to allow before raising a#x1B[39;49;00m #x1B[33m :class:`~urllib3.exceptions.MaxRetryError` exception.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m Pass ``None`` to retry until you receive a response. Pass a#x1B[39;49;00m #x1B[33m :class:`~urllib3.util.retry.Retry` object for fine-grained control#x1B[39;49;00m #x1B[33m over different types of retries.#x1B[39;49;00m #x1B[33m Pass an integer number to retry connection errors that many times,#x1B[39;49;00m #x1B[33m but no other types of errors. Pass zero to never retry.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m If ``False``, then retries are disabled and any exception is raised#x1B[39;49;00m #x1B[33m immediately. Also, instead of raising a MaxRetryError on redirects,#x1B[39;49;00m #x1B[33m the redirect response will be returned.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param redirect:#x1B[39;49;00m #x1B[33m If True, automatically handle redirects (status codes 301, 302,#x1B[39;49;00m #x1B[33m 303, 307, 308). Each redirect counts as a retry. Disabling retries#x1B[39;49;00m #x1B[33m will disable redirect, too.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param assert_same_host:#x1B[39;49;00m #x1B[33m If ``True``, will make sure that the host of the pool requests is#x1B[39;49;00m #x1B[33m consistent else will raise HostChangedError. When ``False``, you can#x1B[39;49;00m #x1B[33m use the pool on an HTTP proxy and request foreign hosts.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param timeout:#x1B[39;49;00m #x1B[33m If specified, overrides the default timeout for this one#x1B[39;49;00m #x1B[33m request. It may be a float (in seconds) or an instance of#x1B[39;49;00m #x1B[33m :class:`urllib3.util.Timeout`.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param pool_timeout:#x1B[39;49;00m #x1B[33m If set and the pool is set to block=True, then this method will#x1B[39;49;00m #x1B[33m block for ``pool_timeout`` seconds and raise EmptyPoolError if no#x1B[39;49;00m #x1B[33m connection is available within the time period.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param release_conn:#x1B[39;49;00m #x1B[33m If False, then the urlopen call will not release the connection#x1B[39;49;00m #x1B[33m back into the pool once a response is received (but will release if#x1B[39;49;00m #x1B[33m you read the entire contents of the response such as when#x1B[39;49;00m #x1B[33m `preload_content=True`). This is useful if you're not preloading#x1B[39;49;00m #x1B[33m the response's content immediately. You will need to call#x1B[39;49;00m #x1B[33m ``r.release_conn()`` on the response ``r`` to return the connection#x1B[39;49;00m #x1B[33m back into the pool. If None, it takes the value of#x1B[39;49;00m #x1B[33m ``response_kw.get('preload_content', True)``.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param chunked:#x1B[39;49;00m #x1B[33m If True, urllib3 will send the body using chunked transfer#x1B[39;49;00m #x1B[33m encoding. Otherwise, urllib3 will send the body using the standard#x1B[39;49;00m #x1B[33m content-length form. Defaults to False.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param int body_pos:#x1B[39;49;00m #x1B[33m Position to seek to in file-like body in the event of a retry or#x1B[39;49;00m #x1B[33m redirect. Typically this won't need to be set because urllib3 will#x1B[39;49;00m #x1B[33m auto-populate the value when needed.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param \\**response_kw:#x1B[39;49;00m #x1B[33m Additional parameters are passed to#x1B[39;49;00m #x1B[33m :meth:`urllib3.response.HTTPResponse.from_httplib`#x1B[39;49;00m #x1B[33m """#x1B[39;49;00m parsed_url = parse_url(url) destination_scheme = parsed_url.scheme #x1B[94mif#x1B[39;49;00m headers #x1B[95mis#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m: headers = #x1B[96mself#x1B[39;49;00m.headers #x1B[94mif#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(retries, Retry): retries = Retry.from_int(retries, redirect=redirect, default=#x1B[96mself#x1B[39;49;00m.retries) #x1B[94mif#x1B[39;49;00m release_conn #x1B[95mis#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m: release_conn = response_kw.get(#x1B[33m"#x1B[39;49;00m#x1B[33mpreload_content#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[94mTrue#x1B[39;49;00m) #x1B[90m# Check host#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m assert_same_host #x1B[95mand#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.is_same_host(url): #x1B[94mraise#x1B[39;49;00m HostChangedError(#x1B[96mself#x1B[39;49;00m, url, retries) #x1B[90m# Ensure that the URL we're connecting to is properly encoded#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m url.startswith(#x1B[33m"#x1B[39;49;00m#x1B[33m/#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m): url = six.ensure_str(_encode_target(url)) #x1B[94melse#x1B[39;49;00m: url = six.ensure_str(parsed_url.url) conn = #x1B[94mNone#x1B[39;49;00m #x1B[90m# Track whether `conn` needs to be released before#x1B[39;49;00m #x1B[90m# returning/raising/recursing. Update this variable if necessary, and#x1B[39;49;00m #x1B[90m# leave `release_conn` constant throughout the function. That way, if#x1B[39;49;00m #x1B[90m# the function recurses, the original value of `release_conn` will be#x1B[39;49;00m #x1B[90m# passed down into the recursive call, and its value will be respected.#x1B[39;49;00m #x1B[90m##x1B[39;49;00m #x1B[90m# See issue #651 [1] for details.#x1B[39;49;00m #x1B[90m##x1B[39;49;00m #x1B[90m# [1] <https://github.com/urllib3/urllib3/issues/651>#x1B[39;49;00m release_this_conn = release_conn http_tunnel_required = connection_requires_http_tunnel( #x1B[96mself#x1B[39;49;00m.proxy, #x1B[96mself#x1B[39;49;00m.proxy_config, destination_scheme ) #x1B[90m# Merge the proxy headers. Only done when not using HTTP CONNECT. We#x1B[39;49;00m #x1B[90m# have to copy the headers dict so we can safely change it without those#x1B[39;49;00m #x1B[90m# changes being reflected in anyone else's copy.#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m http_tunnel_required: headers = headers.copy() headers.update(#x1B[96mself#x1B[39;49;00m.proxy_headers) #x1B[90m# Must keep the exception bound to a separate variable or else Python 3#x1B[39;49;00m #x1B[90m# complains about UnboundLocalError.#x1B[39;49;00m err = #x1B[94mNone#x1B[39;49;00m #x1B[90m# Keep track of whether we cleanly exited the except block. This#x1B[39;49;00m #x1B[90m# ensures we do proper cleanup in finally.#x1B[39;49;00m clean_exit = #x1B[94mFalse#x1B[39;49;00m #x1B[90m# Rewind body position, if needed. Record current position#x1B[39;49;00m #x1B[90m# for future rewinds in the event of a redirect/retry.#x1B[39;49;00m body_pos = set_file_position(body, body_pos) #x1B[94mtry#x1B[39;49;00m: #x1B[90m# Request a connection from the queue.#x1B[39;49;00m timeout_obj = #x1B[96mself#x1B[39;49;00m._get_timeout(timeout) conn = #x1B[96mself#x1B[39;49;00m._get_conn(timeout=pool_timeout) conn.timeout = timeout_obj.connect_timeout is_new_proxy_conn = #x1B[96mself#x1B[39;49;00m.proxy #x1B[95mis#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m #x1B[95mand#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[96mgetattr#x1B[39;49;00m( conn, #x1B[33m"#x1B[39;49;00m#x1B[33msock#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[94mNone#x1B[39;49;00m ) #x1B[94mif#x1B[39;49;00m is_new_proxy_conn #x1B[95mand#x1B[39;49;00m http_tunnel_required: #x1B[96mself#x1B[39;49;00m._prepare_proxy(conn) #x1B[90m# Make the request on the httplib connection object.#x1B[39;49;00m httplib_response = #x1B[96mself#x1B[39;49;00m._make_request( conn, method, url, timeout=timeout_obj, body=body, headers=headers, chunked=chunked, ) #x1B[90m# If we're going to release the connection in ``finally:``, then#x1B[39;49;00m #x1B[90m# the response doesn't need to know about the connection. Otherwise#x1B[39;49;00m #x1B[90m# it will also try to release it and we'll have a double-release#x1B[39;49;00m #x1B[90m# mess.#x1B[39;49;00m response_conn = conn #x1B[94mif#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m release_conn #x1B[94melse#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m #x1B[90m# Pass method to Response for length checking#x1B[39;49;00m response_kw[#x1B[33m"#x1B[39;49;00m#x1B[33mrequest_method#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m] = method #x1B[90m# Import httplib's response into our own wrapper object#x1B[39;49;00m response = #x1B[96mself#x1B[39;49;00m.ResponseCls.from_httplib( httplib_response, pool=#x1B[96mself#x1B[39;49;00m, connection=response_conn, retries=retries, **response_kw ) #x1B[90m# Everything went great!#x1B[39;49;00m clean_exit = #x1B[94mTrue#x1B[39;49;00m #x1B[94mexcept#x1B[39;49;00m EmptyPoolError: #x1B[90m# Didn't get a connection from the pool, no need to clean up#x1B[39;49;00m clean_exit = #x1B[94mTrue#x1B[39;49;00m release_this_conn = #x1B[94mFalse#x1B[39;49;00m #x1B[94mraise#x1B[39;49;00m #x1B[94mexcept#x1B[39;49;00m ( #x1B[96mTimeoutError#x1B[39;49;00m, HTTPException, SocketError, ProtocolError, BaseSSLError, SSLError, CertificateError, ) #x1B[94mas#x1B[39;49;00m e: #x1B[90m# Discard the connection for these exceptions. It will be#x1B[39;49;00m #x1B[90m# replaced during the next _get_conn() call.#x1B[39;49;00m clean_exit = #x1B[94mFalse#x1B[39;49;00m #x1B[94mdef#x1B[39;49;00m #x1B[92m_is_ssl_error_message_from_http_proxy#x1B[39;49;00m(ssl_error): #x1B[90m# We're trying to detect the message 'WRONG_VERSION_NUMBER' but#x1B[39;49;00m #x1B[90m# SSLErrors are kinda all over the place when it comes to the message,#x1B[39;49;00m #x1B[90m# so we try to cover our bases here!#x1B[39;49;00m message = #x1B[33m"#x1B[39;49;00m#x1B[33m #x1B[39;49;00m#x1B[33m"#x1B[39;49;00m.join(re.split(#x1B[33m"#x1B[39;49;00m#x1B[33m[^a-z]#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[96mstr#x1B[39;49;00m(ssl_error).lower())) #x1B[94mreturn#x1B[39;49;00m ( #x1B[33m"#x1B[39;49;00m#x1B[33mwrong version number#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[95min#x1B[39;49;00m message #x1B[95mor#x1B[39;49;00m #x1B[33m"#x1B[39;49;00m#x1B[33munknown protocol#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[95min#x1B[39;49;00m message ) #x1B[90m# Try to detect a common user error with proxies which is to#x1B[39;49;00m #x1B[90m# set an HTTP proxy to be HTTPS when it should be 'http://'#x1B[39;49;00m #x1B[90m# (ie {'http': 'http://proxy', 'https': 'https://proxy'})#x1B[39;49;00m #x1B[90m# Instead we add a nice error message and point to a URL.#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m ( #x1B[96misinstance#x1B[39;49;00m(e, BaseSSLError) #x1B[95mand#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.proxy #x1B[95mand#x1B[39;49;00m _is_ssl_error_message_from_http_proxy(e) ): e = ProxyError( #x1B[33m"#x1B[39;49;00m#x1B[33mYour proxy appears to only use HTTP and not HTTPS, #x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[33m"#x1B[39;49;00m#x1B[33mtry changing your proxy URL to be HTTP. See: #x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[33m"#x1B[39;49;00m#x1B[33mhttps://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[33m"#x1B[39;49;00m#x1B[33m#https-proxy-error-http-proxy#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, SSLError(e), ) #x1B[94melif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(e, (BaseSSLError, CertificateError)): e = SSLError(e) #x1B[94melif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(e, (SocketError, NewConnectionError)) #x1B[95mand#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.proxy: e = ProxyError(#x1B[33m"#x1B[39;49;00m#x1B[33mCannot connect to proxy.#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, e) #x1B[94melif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(e, (SocketError, HTTPException)): e = ProtocolError(#x1B[33m"#x1B[39;49;00m#x1B[33mConnection aborted.#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, e) > retries = retries.increment( method, url, error=e, _pool=#x1B[96mself#x1B[39;49;00m, _stacktrace=sys.exc_info()[#x1B[94m2#x1B[39;49;00m] ) #x1B[1m#x1B[31m/usr/lib/python3/dist-packages/urllib3/connectionpool.py#x1B[0m:785: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = Retry(total=0, connect=None, read=False, redirect=None, status=None), method = 'GET', url = '/', response = None error = ReadTimeoutError("HTTPConnectionPool(host='10.255.255.1', port=80): Read timed out. (read timeout=0.1)") _pool = <urllib3.connectionpool.HTTPConnectionPool object at 0x7f5e369faad0> _stacktrace = <traceback object at 0x7f5e36880e80> #x1B[94mdef#x1B[39;49;00m #x1B[92mincrement#x1B[39;49;00m( #x1B[96mself#x1B[39;49;00m, method=#x1B[94mNone#x1B[39;49;00m, url=#x1B[94mNone#x1B[39;49;00m, response=#x1B[94mNone#x1B[39;49;00m, error=#x1B[94mNone#x1B[39;49;00m, _pool=#x1B[94mNone#x1B[39;49;00m, _stacktrace=#x1B[94mNone#x1B[39;49;00m, ): #x1B[33m"""Return a new Retry object with incremented retry counters.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param response: A response object, or None, if the server did not#x1B[39;49;00m #x1B[33m return a response.#x1B[39;49;00m #x1B[33m :type response: :class:`~urllib3.response.HTTPResponse`#x1B[39;49;00m #x1B[33m :param Exception error: An error encountered during the request, or#x1B[39;49;00m #x1B[33m None if the response was received successfully.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :return: A new ``Retry`` object.#x1B[39;49;00m #x1B[33m """#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.total #x1B[95mis#x1B[39;49;00m #x1B[94mFalse#x1B[39;49;00m #x1B[95mand#x1B[39;49;00m error: #x1B[90m# Disabled, indicate to re-raise the error.#x1B[39;49;00m #x1B[94mraise#x1B[39;49;00m six.reraise(#x1B[96mtype#x1B[39;49;00m(error), error, _stacktrace) total = #x1B[96mself#x1B[39;49;00m.total #x1B[94mif#x1B[39;49;00m total #x1B[95mis#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m: total -= #x1B[94m1#x1B[39;49;00m connect = #x1B[96mself#x1B[39;49;00m.connect read = #x1B[96mself#x1B[39;49;00m.read redirect = #x1B[96mself#x1B[39;49;00m.redirect status_count = #x1B[96mself#x1B[39;49;00m.status other = #x1B[96mself#x1B[39;49;00m.other cause = #x1B[33m"#x1B[39;49;00m#x1B[33munknown#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m status = #x1B[94mNone#x1B[39;49;00m redirect_location = #x1B[94mNone#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m error #x1B[95mand#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m._is_connection_error(error): #x1B[90m# Connect retry?#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m connect #x1B[95mis#x1B[39;49;00m #x1B[94mFalse#x1B[39;49;00m: #x1B[94mraise#x1B[39;49;00m six.reraise(#x1B[96mtype#x1B[39;49;00m(error), error, _stacktrace) #x1B[94melif#x1B[39;49;00m connect #x1B[95mis#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m: connect -= #x1B[94m1#x1B[39;49;00m #x1B[94melif#x1B[39;49;00m error #x1B[95mand#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m._is_read_error(error): #x1B[90m# Read retry?#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m read #x1B[95mis#x1B[39;49;00m #x1B[94mFalse#x1B[39;49;00m #x1B[95mor#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m._is_method_retryable(method): > #x1B[94mraise#x1B[39;49;00m six.reraise(#x1B[96mtype#x1B[39;49;00m(error), error, _stacktrace) #x1B[1m#x1B[31m/usr/lib/python3/dist-packages/urllib3/util/retry.py#x1B[0m:550: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tp = <class 'urllib3.exceptions.ReadTimeoutError'>, value = None, tb = None #x1B[94mdef#x1B[39;49;00m #x1B[92mreraise#x1B[39;49;00m(tp, value, tb=#x1B[94mNone#x1B[39;49;00m): #x1B[94mtry#x1B[39;49;00m: #x1B[94mif#x1B[39;49;00m value #x1B[95mis#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m: value = tp() #x1B[94mif#x1B[39;49;00m value.__traceback__ #x1B[95mis#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m tb: #x1B[94mraise#x1B[39;49;00m value.with_traceback(tb) > #x1B[94mraise#x1B[39;49;00m value #x1B[1m#x1B[31m/usr/lib/python3/dist-packages/urllib3/packages/six.py#x1B[0m:770: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <urllib3.connectionpool.HTTPConnectionPool object at 0x7f5e369faad0>, method = 'GET', url = '/', body = None headers = {'User-Agent': 'python-requests/2.28.0', 'Accept-Encoding': 'gzip, deflate, br', 'Accept': '*/*', 'Connection': 'keep-alive'} retries = Retry(total=0, connect=None, read=False, redirect=None, status=None), redirect = False, assert_same_host = False timeout = Timeout(connect=0.1, read=0.1, total=None), pool_timeout = None, release_conn = False, chunked = False body_pos = None, response_kw = {'decode_content': False, 'preload_content': False} parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/', query=None, fragment=None) destination_scheme = None, conn = None, release_this_conn = True, http_tunnel_required = False, err = None clean_exit = False #x1B[94mdef#x1B[39;49;00m #x1B[92murlopen#x1B[39;49;00m( #x1B[96mself#x1B[39;49;00m, method, url, body=#x1B[94mNone#x1B[39;49;00m, headers=#x1B[94mNone#x1B[39;49;00m, retries=#x1B[94mNone#x1B[39;49;00m, redirect=#x1B[94mTrue#x1B[39;49;00m, assert_same_host=#x1B[94mTrue#x1B[39;49;00m, timeout=_Default, pool_timeout=#x1B[94mNone#x1B[39;49;00m, release_conn=#x1B[94mNone#x1B[39;49;00m, chunked=#x1B[94mFalse#x1B[39;49;00m, body_pos=#x1B[94mNone#x1B[39;49;00m, **response_kw ): #x1B[33m"""#x1B[39;49;00m #x1B[33m Get a connection from the pool and perform an HTTP request. This is the#x1B[39;49;00m #x1B[33m lowest level call for making a request, so you'll need to specify all#x1B[39;49;00m #x1B[33m the raw details.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m .. note::#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m More commonly, it's appropriate to use a convenience method provided#x1B[39;49;00m #x1B[33m by :class:`.RequestMethods`, such as :meth:`request`.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m .. note::#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m `release_conn` will only behave as expected if#x1B[39;49;00m #x1B[33m `preload_content=False` because we want to make#x1B[39;49;00m #x1B[33m `preload_content=False` the default behaviour someday soon without#x1B[39;49;00m #x1B[33m breaking backwards compatibility.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param method:#x1B[39;49;00m #x1B[33m HTTP request method (such as GET, POST, PUT, etc.)#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param url:#x1B[39;49;00m #x1B[33m The URL to perform the request on.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param body:#x1B[39;49;00m #x1B[33m Data to send in the request body, either :class:`str`, :class:`bytes`,#x1B[39;49;00m #x1B[33m an iterable of :class:`str`/:class:`bytes`, or a file-like object.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param headers:#x1B[39;49;00m #x1B[33m Dictionary of custom headers to send, such as User-Agent,#x1B[39;49;00m #x1B[33m If-None-Match, etc. If None, pool headers are used. If provided,#x1B[39;49;00m #x1B[33m these headers completely replace any pool-specific headers.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param retries:#x1B[39;49;00m #x1B[33m Configure the number of retries to allow before raising a#x1B[39;49;00m #x1B[33m :class:`~urllib3.exceptions.MaxRetryError` exception.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m Pass ``None`` to retry until you receive a response. Pass a#x1B[39;49;00m #x1B[33m :class:`~urllib3.util.retry.Retry` object for fine-grained control#x1B[39;49;00m #x1B[33m over different types of retries.#x1B[39;49;00m #x1B[33m Pass an integer number to retry connection errors that many times,#x1B[39;49;00m #x1B[33m but no other types of errors. Pass zero to never retry.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m If ``False``, then retries are disabled and any exception is raised#x1B[39;49;00m #x1B[33m immediately. Also, instead of raising a MaxRetryError on redirects,#x1B[39;49;00m #x1B[33m the redirect response will be returned.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param redirect:#x1B[39;49;00m #x1B[33m If True, automatically handle redirects (status codes 301, 302,#x1B[39;49;00m #x1B[33m 303, 307, 308). Each redirect counts as a retry. Disabling retries#x1B[39;49;00m #x1B[33m will disable redirect, too.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param assert_same_host:#x1B[39;49;00m #x1B[33m If ``True``, will make sure that the host of the pool requests is#x1B[39;49;00m #x1B[33m consistent else will raise HostChangedError. When ``False``, you can#x1B[39;49;00m #x1B[33m use the pool on an HTTP proxy and request foreign hosts.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param timeout:#x1B[39;49;00m #x1B[33m If specified, overrides the default timeout for this one#x1B[39;49;00m #x1B[33m request. It may be a float (in seconds) or an instance of#x1B[39;49;00m #x1B[33m :class:`urllib3.util.Timeout`.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param pool_timeout:#x1B[39;49;00m #x1B[33m If set and the pool is set to block=True, then this method will#x1B[39;49;00m #x1B[33m block for ``pool_timeout`` seconds and raise EmptyPoolError if no#x1B[39;49;00m #x1B[33m connection is available within the time period.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param release_conn:#x1B[39;49;00m #x1B[33m If False, then the urlopen call will not release the connection#x1B[39;49;00m #x1B[33m back into the pool once a response is received (but will release if#x1B[39;49;00m #x1B[33m you read the entire contents of the response such as when#x1B[39;49;00m #x1B[33m `preload_content=True`). This is useful if you're not preloading#x1B[39;49;00m #x1B[33m the response's content immediately. You will need to call#x1B[39;49;00m #x1B[33m ``r.release_conn()`` on the response ``r`` to return the connection#x1B[39;49;00m #x1B[33m back into the pool. If None, it takes the value of#x1B[39;49;00m #x1B[33m ``response_kw.get('preload_content', True)``.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param chunked:#x1B[39;49;00m #x1B[33m If True, urllib3 will send the body using chunked transfer#x1B[39;49;00m #x1B[33m encoding. Otherwise, urllib3 will send the body using the standard#x1B[39;49;00m #x1B[33m content-length form. Defaults to False.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param int body_pos:#x1B[39;49;00m #x1B[33m Position to seek to in file-like body in the event of a retry or#x1B[39;49;00m #x1B[33m redirect. Typically this won't need to be set because urllib3 will#x1B[39;49;00m #x1B[33m auto-populate the value when needed.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param \\**response_kw:#x1B[39;49;00m #x1B[33m Additional parameters are passed to#x1B[39;49;00m #x1B[33m :meth:`urllib3.response.HTTPResponse.from_httplib`#x1B[39;49;00m #x1B[33m """#x1B[39;49;00m parsed_url = parse_url(url) destination_scheme = parsed_url.scheme #x1B[94mif#x1B[39;49;00m headers #x1B[95mis#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m: headers = #x1B[96mself#x1B[39;49;00m.headers #x1B[94mif#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(retries, Retry): retries = Retry.from_int(retries, redirect=redirect, default=#x1B[96mself#x1B[39;49;00m.retries) #x1B[94mif#x1B[39;49;00m release_conn #x1B[95mis#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m: release_conn = response_kw.get(#x1B[33m"#x1B[39;49;00m#x1B[33mpreload_content#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[94mTrue#x1B[39;49;00m) #x1B[90m# Check host#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m assert_same_host #x1B[95mand#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.is_same_host(url): #x1B[94mraise#x1B[39;49;00m HostChangedError(#x1B[96mself#x1B[39;49;00m, url, retries) #x1B[90m# Ensure that the URL we're connecting to is properly encoded#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m url.startswith(#x1B[33m"#x1B[39;49;00m#x1B[33m/#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m): url = six.ensure_str(_encode_target(url)) #x1B[94melse#x1B[39;49;00m: url = six.ensure_str(parsed_url.url) conn = #x1B[94mNone#x1B[39;49;00m #x1B[90m# Track whether `conn` needs to be released before#x1B[39;49;00m #x1B[90m# returning/raising/recursing. Update this variable if necessary, and#x1B[39;49;00m #x1B[90m# leave `release_conn` constant throughout the function. That way, if#x1B[39;49;00m #x1B[90m# the function recurses, the original value of `release_conn` will be#x1B[39;49;00m #x1B[90m# passed down into the recursive call, and its value will be respected.#x1B[39;49;00m #x1B[90m##x1B[39;49;00m #x1B[90m# See issue #651 [1] for details.#x1B[39;49;00m #x1B[90m##x1B[39;49;00m #x1B[90m# [1] <https://github.com/urllib3/urllib3/issues/651>#x1B[39;49;00m release_this_conn = release_conn http_tunnel_required = connection_requires_http_tunnel( #x1B[96mself#x1B[39;49;00m.proxy, #x1B[96mself#x1B[39;49;00m.proxy_config, destination_scheme ) #x1B[90m# Merge the proxy headers. Only done when not using HTTP CONNECT. We#x1B[39;49;00m #x1B[90m# have to copy the headers dict so we can safely change it without those#x1B[39;49;00m #x1B[90m# changes being reflected in anyone else's copy.#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m http_tunnel_required: headers = headers.copy() headers.update(#x1B[96mself#x1B[39;49;00m.proxy_headers) #x1B[90m# Must keep the exception bound to a separate variable or else Python 3#x1B[39;49;00m #x1B[90m# complains about UnboundLocalError.#x1B[39;49;00m err = #x1B[94mNone#x1B[39;49;00m #x1B[90m# Keep track of whether we cleanly exited the except block. This#x1B[39;49;00m #x1B[90m# ensures we do proper cleanup in finally.#x1B[39;49;00m clean_exit = #x1B[94mFalse#x1B[39;49;00m #x1B[90m# Rewind body position, if needed. Record current position#x1B[39;49;00m #x1B[90m# for future rewinds in the event of a redirect/retry.#x1B[39;49;00m body_pos = set_file_position(body, body_pos) #x1B[94mtry#x1B[39;49;00m: #x1B[90m# Request a connection from the queue.#x1B[39;49;00m timeout_obj = #x1B[96mself#x1B[39;49;00m._get_timeout(timeout) conn = #x1B[96mself#x1B[39;49;00m._get_conn(timeout=pool_timeout) conn.timeout = timeout_obj.connect_timeout is_new_proxy_conn = #x1B[96mself#x1B[39;49;00m.proxy #x1B[95mis#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m #x1B[95mand#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[96mgetattr#x1B[39;49;00m( conn, #x1B[33m"#x1B[39;49;00m#x1B[33msock#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[94mNone#x1B[39;49;00m ) #x1B[94mif#x1B[39;49;00m is_new_proxy_conn #x1B[95mand#x1B[39;49;00m http_tunnel_required: #x1B[96mself#x1B[39;49;00m._prepare_proxy(conn) #x1B[90m# Make the request on the httplib connection object.#x1B[39;49;00m > httplib_response = #x1B[96mself#x1B[39;49;00m._make_request( conn, method, url, timeout=timeout_obj, body=body, headers=headers, chunked=chunked, ) #x1B[1m#x1B[31m/usr/lib/python3/dist-packages/urllib3/connectionpool.py#x1B[0m:703: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <urllib3.connectionpool.HTTPConnectionPool object at 0x7f5e369faad0> conn = <urllib3.connection.HTTPConnection object at 0x7f5e369f8490>, method = 'GET', url = '/' timeout = Timeout(connect=0.1, read=0.1, total=None), chunked = False httplib_request_kw = {'body': None, 'headers': {'User-Agent': 'python-requests/2.28.0', 'Accept-Encoding': 'gzip, deflate, br', 'Accept': '*/*', 'Connection': 'keep-alive'}} timeout_obj = Timeout(connect=0.1, read=0.1, total=None), read_timeout = 0.1 #x1B[94mdef#x1B[39;49;00m #x1B[92m_make_request#x1B[39;49;00m( #x1B[96mself#x1B[39;49;00m, conn, method, url, timeout=_Default, chunked=#x1B[94mFalse#x1B[39;49;00m, **httplib_request_kw ): #x1B[33m"""#x1B[39;49;00m #x1B[33m Perform a request on a given urllib connection object taken from our#x1B[39;49;00m #x1B[33m pool.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param conn:#x1B[39;49;00m #x1B[33m a connection from one of our connection pools#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param timeout:#x1B[39;49;00m #x1B[33m Socket timeout in seconds for the request. This can be a#x1B[39;49;00m #x1B[33m float or integer, which will set the same timeout value for#x1B[39;49;00m #x1B[33m the socket connect and the socket read, or an instance of#x1B[39;49;00m #x1B[33m :class:`urllib3.util.Timeout`, which gives you more fine-grained#x1B[39;49;00m #x1B[33m control over your timeouts.#x1B[39;49;00m #x1B[33m """#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.num_requests += #x1B[94m1#x1B[39;49;00m timeout_obj = #x1B[96mself#x1B[39;49;00m._get_timeout(timeout) timeout_obj.start_connect() conn.timeout = timeout_obj.connect_timeout #x1B[90m# Trigger any extra validation we need to do.#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: #x1B[96mself#x1B[39;49;00m._validate_conn(conn) #x1B[94mexcept#x1B[39;49;00m (SocketTimeout, BaseSSLError) #x1B[94mas#x1B[39;49;00m e: #x1B[90m# Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout.#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m._raise_timeout(err=e, url=url, timeout_value=conn.timeout) #x1B[94mraise#x1B[39;49;00m #x1B[90m# conn.request() calls http.client.*.request, not the method in#x1B[39;49;00m #x1B[90m# urllib3.request. It also calls makefile (recv) on the socket.#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: #x1B[94mif#x1B[39;49;00m chunked: conn.request_chunked(method, url, **httplib_request_kw) #x1B[94melse#x1B[39;49;00m: conn.request(method, url, **httplib_request_kw) #x1B[90m# We are swallowing BrokenPipeError (errno.EPIPE) since the server is#x1B[39;49;00m #x1B[90m# legitimately able to close the connection after sending a valid response.#x1B[39;49;00m #x1B[90m# With this behaviour, the received response is still readable.#x1B[39;49;00m #x1B[94mexcept#x1B[39;49;00m #x1B[96mBrokenPipeError#x1B[39;49;00m: #x1B[90m# Python 3#x1B[39;49;00m #x1B[94mpass#x1B[39;49;00m #x1B[94mexcept#x1B[39;49;00m #x1B[96mIOError#x1B[39;49;00m #x1B[94mas#x1B[39;49;00m e: #x1B[90m# Python 2 and macOS/Linux#x1B[39;49;00m #x1B[90m# EPIPE and ESHUTDOWN are BrokenPipeError on Python 2, and EPROTOTYPE is needed on macOS#x1B[39;49;00m #x1B[90m# https://erickt.github.io/blog/2014/11/19/adventures-in-debugging-a-potential-osx-kernel-bug/#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m e.errno #x1B[95mnot#x1B[39;49;00m #x1B[95min#x1B[39;49;00m { errno.EPIPE, errno.ESHUTDOWN, errno.EPROTOTYPE, }: #x1B[94mraise#x1B[39;49;00m #x1B[90m# Reset the timeout for the recv() on the socket#x1B[39;49;00m read_timeout = timeout_obj.read_timeout #x1B[90m# App Engine doesn't have a sock attr#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m #x1B[96mgetattr#x1B[39;49;00m(conn, #x1B[33m"#x1B[39;49;00m#x1B[33msock#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[94mNone#x1B[39;49;00m): #x1B[90m# In Python 3 socket.py will catch EAGAIN and return None when you#x1B[39;49;00m #x1B[90m# try and read into the file pointer created by http.client, which#x1B[39;49;00m #x1B[90m# instead raises a BadStatusLine exception. Instead of catching#x1B[39;49;00m #x1B[90m# the exception and assuming all BadStatusLine exceptions are read#x1B[39;49;00m #x1B[90m# timeouts, check for a zero timeout before making the request.#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m read_timeout == #x1B[94m0#x1B[39;49;00m: #x1B[94mraise#x1B[39;49;00m ReadTimeoutError( #x1B[96mself#x1B[39;49;00m, url, #x1B[33m"#x1B[39;49;00m#x1B[33mRead timed out. (read timeout=#x1B[39;49;00m#x1B[33m%s#x1B[39;49;00m#x1B[33m)#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m % read_timeout ) #x1B[94mif#x1B[39;49;00m read_timeout #x1B[95mis#x1B[39;49;00m Timeout.DEFAULT_TIMEOUT: conn.sock.settimeout(socket.getdefaulttimeout()) #x1B[94melse#x1B[39;49;00m: #x1B[90m# None or a value#x1B[39;49;00m conn.sock.settimeout(read_timeout) #x1B[90m# Receive the response from the server#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: #x1B[94mtry#x1B[39;49;00m: #x1B[90m# Python 2.7, use buffering of HTTP responses#x1B[39;49;00m httplib_response = conn.getresponse(buffering=#x1B[94mTrue#x1B[39;49;00m) #x1B[94mexcept#x1B[39;49;00m #x1B[96mTypeError#x1B[39;49;00m: #x1B[90m# Python 3#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: httplib_response = conn.getresponse() #x1B[94mexcept#x1B[39;49;00m #x1B[96mBaseException#x1B[39;49;00m #x1B[94mas#x1B[39;49;00m e: #x1B[90m# Remove the TypeError from the exception chain in#x1B[39;49;00m #x1B[90m# Python 3 (including for exceptions like SystemExit).#x1B[39;49;00m #x1B[90m# Otherwise it looks like a bug in the code.#x1B[39;49;00m six.raise_from(e, #x1B[94mNone#x1B[39;49;00m) #x1B[94mexcept#x1B[39;49;00m (SocketTimeout, BaseSSLError, SocketError) #x1B[94mas#x1B[39;49;00m e: > #x1B[96mself#x1B[39;49;00m._raise_timeout(err=e, url=url, timeout_value=read_timeout) #x1B[1m#x1B[31m/usr/lib/python3/dist-packages/urllib3/connectionpool.py#x1B[0m:451: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <urllib3.connectionpool.HTTPConnectionPool object at 0x7f5e369faad0>, err = TimeoutError('timed out'), url = '/' timeout_value = 0.1 #x1B[94mdef#x1B[39;49;00m #x1B[92m_raise_timeout#x1B[39;49;00m(#x1B[96mself#x1B[39;49;00m, err, url, timeout_value): #x1B[33m"""Is the error actually a timeout? Will raise a ReadTimeout or pass"""#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(err, SocketTimeout): > #x1B[94mraise#x1B[39;49;00m ReadTimeoutError( #x1B[96mself#x1B[39;49;00m, url, #x1B[33m"#x1B[39;49;00m#x1B[33mRead timed out. (read timeout=#x1B[39;49;00m#x1B[33m%s#x1B[39;49;00m#x1B[33m)#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m % timeout_value ) #x1B[1m#x1B[31mE urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='10.255.255.1', port=80): Read timed out. (read timeout=0.1)#x1B[0m #x1B[1m#x1B[31m/usr/lib/python3/dist-packages/urllib3/connectionpool.py#x1B[0m:340: ReadTimeoutError #x1B[33mDuring handling of the above exception, another exception occurred:#x1B[0m self = <tests.test_requests.TestTimeout object at 0x7f5e369fb4f0>, timeout = (0.1, 0.1) #x1B[37m@pytest#x1B[39;49;00m.mark.parametrize( #x1B[33m"#x1B[39;49;00m#x1B[33mtimeout#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, ((#x1B[94m0.1#x1B[39;49;00m, #x1B[94m0.1#x1B[39;49;00m), Urllib3Timeout(connect=#x1B[94m0.1#x1B[39;49;00m, read=#x1B[94m0.1#x1B[39;49;00m)) ) #x1B[94mdef#x1B[39;49;00m #x1B[92mtest_total_timeout_connect#x1B[39;49;00m(#x1B[96mself#x1B[39;49;00m, timeout): #x1B[94mtry#x1B[39;49;00m: > requests.get(TARPIT, timeout=timeout) #x1B[1m#x1B[31mtests/test_requests.py#x1B[0m:2444: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ #x1B[1m#x1B[31mrequests/api.py#x1B[0m:73: in get #x1B[94mreturn#x1B[39;49;00m request(#x1B[33m"#x1B[39;49;00m#x1B[33mget#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, url, params=params, **kwargs) #x1B[1m#x1B[31mrequests/api.py#x1B[0m:59: in request #x1B[94mreturn#x1B[39;49;00m session.request(method=method, url=url, **kwargs) #x1B[1m#x1B[31mrequests/sessions.py#x1B[0m:587: in request resp = #x1B[96mself#x1B[39;49;00m.send(prep, **send_kwargs) #x1B[1m#x1B[31mrequests/sessions.py#x1B[0m:701: in send r = adapter.send(request, **kwargs) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <requests.adapters.HTTPAdapter object at 0x7f5e369fbc70>, request = <PreparedRequest [GET]>, stream = False timeout = Timeout(connect=0.1, read=0.1, total=None), verify = True, cert = None, proxies = OrderedDict() #x1B[94mdef#x1B[39;49;00m #x1B[92msend#x1B[39;49;00m( #x1B[96mself#x1B[39;49;00m, request, stream=#x1B[94mFalse#x1B[39;49;00m, timeout=#x1B[94mNone#x1B[39;49;00m, verify=#x1B[94mTrue#x1B[39;49;00m, cert=#x1B[94mNone#x1B[39;49;00m, proxies=#x1B[94mNone#x1B[39;49;00m ): #x1B[33m"""Sends PreparedRequest object. Returns Response object.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param request: The :class:`PreparedRequest <PreparedRequest>` being sent.#x1B[39;49;00m #x1B[33m :param stream: (optional) Whether to stream the request content.#x1B[39;49;00m #x1B[33m :param timeout: (optional) How long to wait for the server to send#x1B[39;49;00m #x1B[33m data before giving up, as a float, or a :ref:`(connect timeout,#x1B[39;49;00m #x1B[33m read timeout) <timeouts>` tuple.#x1B[39;49;00m #x1B[33m :type timeout: float or tuple or urllib3 Timeout object#x1B[39;49;00m #x1B[33m :param verify: (optional) Either a boolean, in which case it controls whether#x1B[39;49;00m #x1B[33m we verify the server's TLS certificate, or a string, in which case it#x1B[39;49;00m #x1B[33m must be a path to a CA bundle to use#x1B[39;49;00m #x1B[33m :param cert: (optional) Any user-provided SSL certificate to be trusted.#x1B[39;49;00m #x1B[33m :param proxies: (optional) The proxies dictionary to apply to the request.#x1B[39;49;00m #x1B[33m :rtype: requests.Response#x1B[39;49;00m #x1B[33m """#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: conn = #x1B[96mself#x1B[39;49;00m.get_connection(request.url, proxies) #x1B[94mexcept#x1B[39;49;00m LocationValueError #x1B[94mas#x1B[39;49;00m e: #x1B[94mraise#x1B[39;49;00m InvalidURL(e, request=request) #x1B[96mself#x1B[39;49;00m.cert_verify(conn, request.url, verify, cert) url = #x1B[96mself#x1B[39;49;00m.request_url(request, proxies) #x1B[96mself#x1B[39;49;00m.add_headers( request, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies, ) chunked = #x1B[95mnot#x1B[39;49;00m (request.body #x1B[95mis#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m #x1B[95mor#x1B[39;49;00m #x1B[33m"#x1B[39;49;00m#x1B[33mContent-Length#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[95min#x1B[39;49;00m request.headers) #x1B[94mif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(timeout, #x1B[96mtuple#x1B[39;49;00m): #x1B[94mtry#x1B[39;49;00m: connect, read = timeout timeout = TimeoutSauce(connect=connect, read=read) #x1B[94mexcept#x1B[39;49;00m #x1B[96mValueError#x1B[39;49;00m: #x1B[94mraise#x1B[39;49;00m #x1B[96mValueError#x1B[39;49;00m( #x1B[33mf#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33mInvalid timeout #x1B[39;49;00m#x1B[33m{#x1B[39;49;00mtimeout#x1B[33m}#x1B[39;49;00m#x1B[33m. Pass a (connect, read) timeout tuple, #x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[33mf#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33mor a single float to set both timeouts to the same value.#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m ) #x1B[94melif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(timeout, TimeoutSauce): #x1B[94mpass#x1B[39;49;00m #x1B[94melse#x1B[39;49;00m: timeout = TimeoutSauce(connect=timeout, read=timeout) #x1B[94mtry#x1B[39;49;00m: #x1B[94mif#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m chunked: resp = conn.urlopen( method=request.method, url=url, body=request.body, headers=request.headers, redirect=#x1B[94mFalse#x1B[39;49;00m, assert_same_host=#x1B[94mFalse#x1B[39;49;00m, preload_content=#x1B[94mFalse#x1B[39;49;00m, decode_content=#x1B[94mFalse#x1B[39;49;00m, retries=#x1B[96mself#x1B[39;49;00m.max_retries, timeout=timeout, ) #x1B[90m# Send the request.#x1B[39;49;00m #x1B[94melse#x1B[39;49;00m: #x1B[94mif#x1B[39;49;00m #x1B[96mhasattr#x1B[39;49;00m(conn, #x1B[33m"#x1B[39;49;00m#x1B[33mproxy_pool#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m): conn = conn.proxy_pool low_conn = conn._get_conn(timeout=DEFAULT_POOL_TIMEOUT) #x1B[94mtry#x1B[39;49;00m: skip_host = #x1B[33m"#x1B[39;49;00m#x1B[33mHost#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[95min#x1B[39;49;00m request.headers low_conn.putrequest( request.method, url, skip_accept_encoding=#x1B[94mTrue#x1B[39;49;00m, skip_host=skip_host, ) #x1B[94mfor#x1B[39;49;00m header, value #x1B[95min#x1B[39;49;00m request.headers.items(): low_conn.putheader(header, value) low_conn.endheaders() #x1B[94mfor#x1B[39;49;00m i #x1B[95min#x1B[39;49;00m request.body: low_conn.send(#x1B[96mhex#x1B[39;49;00m(#x1B[96mlen#x1B[39;49;00m(i))[#x1B[94m2#x1B[39;49;00m:].encode(#x1B[33m"#x1B[39;49;00m#x1B[33mutf-8#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m)) low_conn.send(#x1B[33mb#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33m\r#x1B[39;49;00m#x1B[33m\n#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m) low_conn.send(i) low_conn.send(#x1B[33mb#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33m\r#x1B[39;49;00m#x1B[33m\n#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m) low_conn.send(#x1B[33mb#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33m0#x1B[39;49;00m#x1B[33m\r#x1B[39;49;00m#x1B[33m\n#x1B[39;49;00m#x1B[33m\r#x1B[39;49;00m#x1B[33m\n#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m) #x1B[90m# Receive the response from the server#x1B[39;49;00m r = low_conn.getresponse() resp = HTTPResponse.from_httplib( r, pool=conn, connection=low_conn, preload_content=#x1B[94mFalse#x1B[39;49;00m, decode_content=#x1B[94mFalse#x1B[39;49;00m, ) #x1B[94mexcept#x1B[39;49;00m #x1B[96mException#x1B[39;49;00m: #x1B[90m# If we hit any problems here, clean up the connection.#x1B[39;49;00m #x1B[90m# Then, raise so that we can handle the actual exception.#x1B[39;49;00m low_conn.close() #x1B[94mraise#x1B[39;49;00m #x1B[94mexcept#x1B[39;49;00m (ProtocolError, #x1B[96mOSError#x1B[39;49;00m) #x1B[94mas#x1B[39;49;00m err: #x1B[94mraise#x1B[39;49;00m #x1B[96mConnectionError#x1B[39;49;00m(err, request=request) #x1B[94mexcept#x1B[39;49;00m MaxRetryError #x1B[94mas#x1B[39;49;00m e: #x1B[94mif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(e.reason, ConnectTimeoutError): #x1B[90m# TODO: Remove this in 3.0.0: see #2811#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(e.reason, NewConnectionError): #x1B[94mraise#x1B[39;49;00m ConnectTimeout(e, request=request) #x1B[94mif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(e.reason, ResponseError): #x1B[94mraise#x1B[39;49;00m RetryError(e, request=request) #x1B[94mif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(e.reason, _ProxyError): #x1B[94mraise#x1B[39;49;00m ProxyError(e, request=request) #x1B[94mif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(e.reason, _SSLError): #x1B[90m# This branch is for urllib3 v1.22 and later.#x1B[39;49;00m #x1B[94mraise#x1B[39;49;00m SSLError(e, request=request) #x1B[94mraise#x1B[39;49;00m #x1B[96mConnectionError#x1B[39;49;00m(e, request=request) #x1B[94mexcept#x1B[39;49;00m ClosedPoolError #x1B[94mas#x1B[39;49;00m e: #x1B[94mraise#x1B[39;49;00m #x1B[96mConnectionError#x1B[39;49;00m(e, request=request) #x1B[94mexcept#x1B[39;49;00m _ProxyError #x1B[94mas#x1B[39;49;00m e: #x1B[94mraise#x1B[39;49;00m ProxyError(e) #x1B[94mexcept#x1B[39;49;00m (_SSLError, _HTTPError) #x1B[94mas#x1B[39;49;00m e: #x1B[94mif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(e, _SSLError): #x1B[90m# This branch is for urllib3 versions earlier than v1.22#x1B[39;49;00m #x1B[94mraise#x1B[39;49;00m SSLError(e, request=request) #x1B[94melif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(e, ReadTimeoutError): > #x1B[94mraise#x1B[39;49;00m ReadTimeout(e, request=request) #x1B[1m#x1B[31mE requests.exceptions.ReadTimeout: HTTPConnectionPool(host='10.255.255.1', port=80): Read timed out. (read timeout=0.1)#x1B[0m #x1B[1m#x1B[31mrequests/adapters.py#x1B[0m:578: ReadTimeoutself = <urllib3.connectionpool.HTTPConnectionPool object at 0x7f5e3466a740> conn = <urllib3.connection.HTTPConnection object at 0x7f5e3466a380>, method = 'GET', url = '/' timeout = Timeout(connect=0.1, read=0.1, total=None), chunked = False httplib_request_kw = {'body': None, 'headers': {'User-Agent': 'python-requests/2.28.0', 'Accept-Encoding': 'gzip, deflate, br', 'Accept': '*/*', 'Connection': 'keep-alive'}} timeout_obj = Timeout(connect=0.1, read=0.1, total=None), read_timeout = 0.1 #x1B[94mdef#x1B[39;49;00m #x1B[92m_make_request#x1B[39;49;00m( #x1B[96mself#x1B[39;49;00m, conn, method, url, timeout=_Default, chunked=#x1B[94mFalse#x1B[39;49;00m, **httplib_request_kw ): #x1B[33m"""#x1B[39;49;00m #x1B[33m Perform a request on a given urllib connection object taken from our#x1B[39;49;00m #x1B[33m pool.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param conn:#x1B[39;49;00m #x1B[33m a connection from one of our connection pools#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param timeout:#x1B[39;49;00m #x1B[33m Socket timeout in seconds for the request. This can be a#x1B[39;49;00m #x1B[33m float or integer, which will set the same timeout value for#x1B[39;49;00m #x1B[33m the socket connect and the socket read, or an instance of#x1B[39;49;00m #x1B[33m :class:`urllib3.util.Timeout`, which gives you more fine-grained#x1B[39;49;00m #x1B[33m control over your timeouts.#x1B[39;49;00m #x1B[33m """#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.num_requests += #x1B[94m1#x1B[39;49;00m timeout_obj = #x1B[96mself#x1B[39;49;00m._get_timeout(timeout) timeout_obj.start_connect() conn.timeout = timeout_obj.connect_timeout #x1B[90m# Trigger any extra validation we need to do.#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: #x1B[96mself#x1B[39;49;00m._validate_conn(conn) #x1B[94mexcept#x1B[39;49;00m (SocketTimeout, BaseSSLError) #x1B[94mas#x1B[39;49;00m e: #x1B[90m# Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout.#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m._raise_timeout(err=e, url=url, timeout_value=conn.timeout) #x1B[94mraise#x1B[39;49;00m #x1B[90m# conn.request() calls http.client.*.request, not the method in#x1B[39;49;00m #x1B[90m# urllib3.request. It also calls makefile (recv) on the socket.#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: #x1B[94mif#x1B[39;49;00m chunked: conn.request_chunked(method, url, **httplib_request_kw) #x1B[94melse#x1B[39;49;00m: conn.request(method, url, **httplib_request_kw) #x1B[90m# We are swallowing BrokenPipeError (errno.EPIPE) since the server is#x1B[39;49;00m #x1B[90m# legitimately able to close the connection after sending a valid response.#x1B[39;49;00m #x1B[90m# With this behaviour, the received response is still readable.#x1B[39;49;00m #x1B[94mexcept#x1B[39;49;00m #x1B[96mBrokenPipeError#x1B[39;49;00m: #x1B[90m# Python 3#x1B[39;49;00m #x1B[94mpass#x1B[39;49;00m #x1B[94mexcept#x1B[39;49;00m #x1B[96mIOError#x1B[39;49;00m #x1B[94mas#x1B[39;49;00m e: #x1B[90m# Python 2 and macOS/Linux#x1B[39;49;00m #x1B[90m# EPIPE and ESHUTDOWN are BrokenPipeError on Python 2, and EPROTOTYPE is needed on macOS#x1B[39;49;00m #x1B[90m# https://erickt.github.io/blog/2014/11/19/adventures-in-debugging-a-potential-osx-kernel-bug/#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m e.errno #x1B[95mnot#x1B[39;49;00m #x1B[95min#x1B[39;49;00m { errno.EPIPE, errno.ESHUTDOWN, errno.EPROTOTYPE, }: #x1B[94mraise#x1B[39;49;00m #x1B[90m# Reset the timeout for the recv() on the socket#x1B[39;49;00m read_timeout = timeout_obj.read_timeout #x1B[90m# App Engine doesn't have a sock attr#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m #x1B[96mgetattr#x1B[39;49;00m(conn, #x1B[33m"#x1B[39;49;00m#x1B[33msock#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[94mNone#x1B[39;49;00m): #x1B[90m# In Python 3 socket.py will catch EAGAIN and return None when you#x1B[39;49;00m #x1B[90m# try and read into the file pointer created by http.client, which#x1B[39;49;00m #x1B[90m# instead raises a BadStatusLine exception. Instead of catching#x1B[39;49;00m #x1B[90m# the exception and assuming all BadStatusLine exceptions are read#x1B[39;49;00m #x1B[90m# timeouts, check for a zero timeout before making the request.#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m read_timeout == #x1B[94m0#x1B[39;49;00m: #x1B[94mraise#x1B[39;49;00m ReadTimeoutError( #x1B[96mself#x1B[39;49;00m, url, #x1B[33m"#x1B[39;49;00m#x1B[33mRead timed out. (read timeout=#x1B[39;49;00m#x1B[33m%s#x1B[39;49;00m#x1B[33m)#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m % read_timeout ) #x1B[94mif#x1B[39;49;00m read_timeout #x1B[95mis#x1B[39;49;00m Timeout.DEFAULT_TIMEOUT: conn.sock.settimeout(socket.getdefaulttimeout()) #x1B[94melse#x1B[39;49;00m: #x1B[90m# None or a value#x1B[39;49;00m conn.sock.settimeout(read_timeout) #x1B[90m# Receive the response from the server#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: #x1B[94mtry#x1B[39;49;00m: #x1B[90m# Python 2.7, use buffering of HTTP responses#x1B[39;49;00m httplib_response = conn.getresponse(buffering=#x1B[94mTrue#x1B[39;49;00m) #x1B[94mexcept#x1B[39;49;00m #x1B[96mTypeError#x1B[39;49;00m: #x1B[90m# Python 3#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: httplib_response = conn.getresponse() #x1B[94mexcept#x1B[39;49;00m #x1B[96mBaseException#x1B[39;49;00m #x1B[94mas#x1B[39;49;00m e: #x1B[90m# Remove the TypeError from the exception chain in#x1B[39;49;00m #x1B[90m# Python 3 (including for exceptions like SystemExit).#x1B[39;49;00m #x1B[90m# Otherwise it looks like a bug in the code.#x1B[39;49;00m > six.raise_from(e, #x1B[94mNone#x1B[39;49;00m) #x1B[1m#x1B[31m/usr/lib/python3/dist-packages/urllib3/connectionpool.py#x1B[0m:449: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ value = None, from_value = None > #x1B[04m#x1B[91m?#x1B[39;49;00m#x1B[04m#x1B[91m?#x1B[39;49;00m#x1B[04m#x1B[91m?#x1B[39;49;00m #x1B[1m#x1B[31m<string>#x1B[0m:3: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <urllib3.connectionpool.HTTPConnectionPool object at 0x7f5e3466a740> conn = <urllib3.connection.HTTPConnection object at 0x7f5e3466a380>, method = 'GET', url = '/' timeout = Timeout(connect=0.1, read=0.1, total=None), chunked = False httplib_request_kw = {'body': None, 'headers': {'User-Agent': 'python-requests/2.28.0', 'Accept-Encoding': 'gzip, deflate, br', 'Accept': '*/*', 'Connection': 'keep-alive'}} timeout_obj = Timeout(connect=0.1, read=0.1, total=None), read_timeout = 0.1 #x1B[94mdef#x1B[39;49;00m #x1B[92m_make_request#x1B[39;49;00m( #x1B[96mself#x1B[39;49;00m, conn, method, url, timeout=_Default, chunked=#x1B[94mFalse#x1B[39;49;00m, **httplib_request_kw ): #x1B[33m"""#x1B[39;49;00m #x1B[33m Perform a request on a given urllib connection object taken from our#x1B[39;49;00m #x1B[33m pool.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param conn:#x1B[39;49;00m #x1B[33m a connection from one of our connection pools#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param timeout:#x1B[39;49;00m #x1B[33m Socket timeout in seconds for the request. This can be a#x1B[39;49;00m #x1B[33m float or integer, which will set the same timeout value for#x1B[39;49;00m #x1B[33m the socket connect and the socket read, or an instance of#x1B[39;49;00m #x1B[33m :class:`urllib3.util.Timeout`, which gives you more fine-grained#x1B[39;49;00m #x1B[33m control over your timeouts.#x1B[39;49;00m #x1B[33m """#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.num_requests += #x1B[94m1#x1B[39;49;00m timeout_obj = #x1B[96mself#x1B[39;49;00m._get_timeout(timeout) timeout_obj.start_connect() conn.timeout = timeout_obj.connect_timeout #x1B[90m# Trigger any extra validation we need to do.#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: #x1B[96mself#x1B[39;49;00m._validate_conn(conn) #x1B[94mexcept#x1B[39;49;00m (SocketTimeout, BaseSSLError) #x1B[94mas#x1B[39;49;00m e: #x1B[90m# Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout.#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m._raise_timeout(err=e, url=url, timeout_value=conn.timeout) #x1B[94mraise#x1B[39;49;00m #x1B[90m# conn.request() calls http.client.*.request, not the method in#x1B[39;49;00m #x1B[90m# urllib3.request. It also calls makefile (recv) on the socket.#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: #x1B[94mif#x1B[39;49;00m chunked: conn.request_chunked(method, url, **httplib_request_kw) #x1B[94melse#x1B[39;49;00m: conn.request(method, url, **httplib_request_kw) #x1B[90m# We are swallowing BrokenPipeError (errno.EPIPE) since the server is#x1B[39;49;00m #x1B[90m# legitimately able to close the connection after sending a valid response.#x1B[39;49;00m #x1B[90m# With this behaviour, the received response is still readable.#x1B[39;49;00m #x1B[94mexcept#x1B[39;49;00m #x1B[96mBrokenPipeError#x1B[39;49;00m: #x1B[90m# Python 3#x1B[39;49;00m #x1B[94mpass#x1B[39;49;00m #x1B[94mexcept#x1B[39;49;00m #x1B[96mIOError#x1B[39;49;00m #x1B[94mas#x1B[39;49;00m e: #x1B[90m# Python 2 and macOS/Linux#x1B[39;49;00m #x1B[90m# EPIPE and ESHUTDOWN are BrokenPipeError on Python 2, and EPROTOTYPE is needed on macOS#x1B[39;49;00m #x1B[90m# https://erickt.github.io/blog/2014/11/19/adventures-in-debugging-a-potential-osx-kernel-bug/#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m e.errno #x1B[95mnot#x1B[39;49;00m #x1B[95min#x1B[39;49;00m { errno.EPIPE, errno.ESHUTDOWN, errno.EPROTOTYPE, }: #x1B[94mraise#x1B[39;49;00m #x1B[90m# Reset the timeout for the recv() on the socket#x1B[39;49;00m read_timeout = timeout_obj.read_timeout #x1B[90m# App Engine doesn't have a sock attr#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m #x1B[96mgetattr#x1B[39;49;00m(conn, #x1B[33m"#x1B[39;49;00m#x1B[33msock#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[94mNone#x1B[39;49;00m): #x1B[90m# In Python 3 socket.py will catch EAGAIN and return None when you#x1B[39;49;00m #x1B[90m# try and read into the file pointer created by http.client, which#x1B[39;49;00m #x1B[90m# instead raises a BadStatusLine exception. Instead of catching#x1B[39;49;00m #x1B[90m# the exception and assuming all BadStatusLine exceptions are read#x1B[39;49;00m #x1B[90m# timeouts, check for a zero timeout before making the request.#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m read_timeout == #x1B[94m0#x1B[39;49;00m: #x1B[94mraise#x1B[39;49;00m ReadTimeoutError( #x1B[96mself#x1B[39;49;00m, url, #x1B[33m"#x1B[39;49;00m#x1B[33mRead timed out. (read timeout=#x1B[39;49;00m#x1B[33m%s#x1B[39;49;00m#x1B[33m)#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m % read_timeout ) #x1B[94mif#x1B[39;49;00m read_timeout #x1B[95mis#x1B[39;49;00m Timeout.DEFAULT_TIMEOUT: conn.sock.settimeout(socket.getdefaulttimeout()) #x1B[94melse#x1B[39;49;00m: #x1B[90m# None or a value#x1B[39;49;00m conn.sock.settimeout(read_timeout) #x1B[90m# Receive the response from the server#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: #x1B[94mtry#x1B[39;49;00m: #x1B[90m# Python 2.7, use buffering of HTTP responses#x1B[39;49;00m httplib_response = conn.getresponse(buffering=#x1B[94mTrue#x1B[39;49;00m) #x1B[94mexcept#x1B[39;49;00m #x1B[96mTypeError#x1B[39;49;00m: #x1B[90m# Python 3#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: > httplib_response = conn.getresponse() #x1B[1m#x1B[31m/usr/lib/python3/dist-packages/urllib3/connectionpool.py#x1B[0m:444: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <urllib3.connection.HTTPConnection object at 0x7f5e3466a380> #x1B[94mdef#x1B[39;49;00m #x1B[92mgetresponse#x1B[39;49;00m(#x1B[96mself#x1B[39;49;00m): #x1B[33m"""Get the response from the server.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m If the HTTPConnection is in the correct state, returns an#x1B[39;49;00m #x1B[33m instance of HTTPResponse or of whatever object is returned by#x1B[39;49;00m #x1B[33m the response_class variable.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m If a request has not been sent or if a previous response has#x1B[39;49;00m #x1B[33m not be handled, ResponseNotReady is raised. If the HTTP#x1B[39;49;00m #x1B[33m response indicates that the connection should be closed, then#x1B[39;49;00m #x1B[33m it will be closed before the response is returned. When the#x1B[39;49;00m #x1B[33m connection is closed, the underlying socket is closed.#x1B[39;49;00m #x1B[33m """#x1B[39;49;00m #x1B[90m# if a prior response has been completed, then forget about it.#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.__response #x1B[95mand#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.__response.isclosed(): #x1B[96mself#x1B[39;49;00m.__response = #x1B[94mNone#x1B[39;49;00m #x1B[90m# if a prior response exists, then it must be completed (otherwise, we#x1B[39;49;00m #x1B[90m# cannot read this response's header to determine the connection-close#x1B[39;49;00m #x1B[90m# behavior)#x1B[39;49;00m #x1B[90m##x1B[39;49;00m #x1B[90m# note: if a prior response existed, but was connection-close, then the#x1B[39;49;00m #x1B[90m# socket and response were made independent of this HTTPConnection#x1B[39;49;00m #x1B[90m# object since a new request requires that we open a whole new#x1B[39;49;00m #x1B[90m# connection#x1B[39;49;00m #x1B[90m##x1B[39;49;00m #x1B[90m# this means the prior response had one of two states:#x1B[39;49;00m #x1B[90m# 1) will_close: this connection was reset and the prior socket and#x1B[39;49;00m #x1B[90m# response operate independently#x1B[39;49;00m #x1B[90m# 2) persistent: the response was retained and we await its#x1B[39;49;00m #x1B[90m# isclosed() status to become true.#x1B[39;49;00m #x1B[90m##x1B[39;49;00m #x1B[94mif#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.__state != _CS_REQ_SENT #x1B[95mor#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.__response: #x1B[94mraise#x1B[39;49;00m ResponseNotReady(#x1B[96mself#x1B[39;49;00m.__state) #x1B[94mif#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.debuglevel > #x1B[94m0#x1B[39;49;00m: response = #x1B[96mself#x1B[39;49;00m.response_class(#x1B[96mself#x1B[39;49;00m.sock, #x1B[96mself#x1B[39;49;00m.debuglevel, method=#x1B[96mself#x1B[39;49;00m._method) #x1B[94melse#x1B[39;49;00m: response = #x1B[96mself#x1B[39;49;00m.response_class(#x1B[96mself#x1B[39;49;00m.sock, method=#x1B[96mself#x1B[39;49;00m._method) #x1B[94mtry#x1B[39;49;00m: #x1B[94mtry#x1B[39;49;00m: > response.begin() #x1B[1m#x1B[31m/usr/lib/python3.10/http/client.py#x1B[0m:1374: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <http.client.HTTPResponse object at 0x7f5e3466a4a0> #x1B[94mdef#x1B[39;49;00m #x1B[92mbegin#x1B[39;49;00m(#x1B[96mself#x1B[39;49;00m): #x1B[94mif#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.headers #x1B[95mis#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m: #x1B[90m# we've already started reading the response#x1B[39;49;00m #x1B[94mreturn#x1B[39;49;00m #x1B[90m# read until we get a non-100 response#x1B[39;49;00m #x1B[94mwhile#x1B[39;49;00m #x1B[94mTrue#x1B[39;49;00m: > version, status, reason = #x1B[96mself#x1B[39;49;00m._read_status() #x1B[1m#x1B[31m/usr/lib/python3.10/http/client.py#x1B[0m:318: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <http.client.HTTPResponse object at 0x7f5e3466a4a0> #x1B[94mdef#x1B[39;49;00m #x1B[92m_read_status#x1B[39;49;00m(#x1B[96mself#x1B[39;49;00m): > line = #x1B[96mstr#x1B[39;49;00m(#x1B[96mself#x1B[39;49;00m.fp.readline(_MAXLINE + #x1B[94m1#x1B[39;49;00m), #x1B[33m"#x1B[39;49;00m#x1B[33miso-8859-1#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m) #x1B[1m#x1B[31m/usr/lib/python3.10/http/client.py#x1B[0m:279: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <socket.SocketIO object at 0x7f5e3466a470>, b = <memory at 0x7f5e35f0b640> #x1B[94mdef#x1B[39;49;00m #x1B[92mreadinto#x1B[39;49;00m(#x1B[96mself#x1B[39;49;00m, b): #x1B[33m"""Read up to len(b) bytes into the writable buffer *b* and return#x1B[39;49;00m #x1B[33m the number of bytes read. If the socket is non-blocking and no bytes#x1B[39;49;00m #x1B[33m are available, None is returned.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m If *b* is non-empty, a 0 return value indicates that the connection#x1B[39;49;00m #x1B[33m was shutdown at the other end.#x1B[39;49;00m #x1B[33m """#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m._checkClosed() #x1B[96mself#x1B[39;49;00m._checkReadable() #x1B[94mif#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m._timeout_occurred: #x1B[94mraise#x1B[39;49;00m #x1B[96mOSError#x1B[39;49;00m(#x1B[33m"#x1B[39;49;00m#x1B[33mcannot read from timed out object#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m) #x1B[94mwhile#x1B[39;49;00m #x1B[94mTrue#x1B[39;49;00m: #x1B[94mtry#x1B[39;49;00m: > #x1B[94mreturn#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m._sock.recv_into(b) #x1B[1m#x1B[31mE TimeoutError: timed out#x1B[0m #x1B[1m#x1B[31m/usr/lib/python3.10/socket.py#x1B[0m:705: TimeoutError #x1B[33mDuring handling of the above exception, another exception occurred:#x1B[0m self = <requests.adapters.HTTPAdapter object at 0x7f5e368d8f10>, request = <PreparedRequest [GET]>, stream = False timeout = Timeout(connect=0.1, read=0.1, total=None), verify = True, cert = None, proxies = OrderedDict() #x1B[94mdef#x1B[39;49;00m #x1B[92msend#x1B[39;49;00m( #x1B[96mself#x1B[39;49;00m, request, stream=#x1B[94mFalse#x1B[39;49;00m, timeout=#x1B[94mNone#x1B[39;49;00m, verify=#x1B[94mTrue#x1B[39;49;00m, cert=#x1B[94mNone#x1B[39;49;00m, proxies=#x1B[94mNone#x1B[39;49;00m ): #x1B[33m"""Sends PreparedRequest object. Returns Response object.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param request: The :class:`PreparedRequest <PreparedRequest>` being sent.#x1B[39;49;00m #x1B[33m :param stream: (optional) Whether to stream the request content.#x1B[39;49;00m #x1B[33m :param timeout: (optional) How long to wait for the server to send#x1B[39;49;00m #x1B[33m data before giving up, as a float, or a :ref:`(connect timeout,#x1B[39;49;00m #x1B[33m read timeout) <timeouts>` tuple.#x1B[39;49;00m #x1B[33m :type timeout: float or tuple or urllib3 Timeout object#x1B[39;49;00m #x1B[33m :param verify: (optional) Either a boolean, in which case it controls whether#x1B[39;49;00m #x1B[33m we verify the server's TLS certificate, or a string, in which case it#x1B[39;49;00m #x1B[33m must be a path to a CA bundle to use#x1B[39;49;00m #x1B[33m :param cert: (optional) Any user-provided SSL certificate to be trusted.#x1B[39;49;00m #x1B[33m :param proxies: (optional) The proxies dictionary to apply to the request.#x1B[39;49;00m #x1B[33m :rtype: requests.Response#x1B[39;49;00m #x1B[33m """#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: conn = #x1B[96mself#x1B[39;49;00m.get_connection(request.url, proxies) #x1B[94mexcept#x1B[39;49;00m LocationValueError #x1B[94mas#x1B[39;49;00m e: #x1B[94mraise#x1B[39;49;00m InvalidURL(e, request=request) #x1B[96mself#x1B[39;49;00m.cert_verify(conn, request.url, verify, cert) url = #x1B[96mself#x1B[39;49;00m.request_url(request, proxies) #x1B[96mself#x1B[39;49;00m.add_headers( request, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies, ) chunked = #x1B[95mnot#x1B[39;49;00m (request.body #x1B[95mis#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m #x1B[95mor#x1B[39;49;00m #x1B[33m"#x1B[39;49;00m#x1B[33mContent-Length#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[95min#x1B[39;49;00m request.headers) #x1B[94mif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(timeout, #x1B[96mtuple#x1B[39;49;00m): #x1B[94mtry#x1B[39;49;00m: connect, read = timeout timeout = TimeoutSauce(connect=connect, read=read) #x1B[94mexcept#x1B[39;49;00m #x1B[96mValueError#x1B[39;49;00m: #x1B[94mraise#x1B[39;49;00m #x1B[96mValueError#x1B[39;49;00m( #x1B[33mf#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33mInvalid timeout #x1B[39;49;00m#x1B[33m{#x1B[39;49;00mtimeout#x1B[33m}#x1B[39;49;00m#x1B[33m. Pass a (connect, read) timeout tuple, #x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[33mf#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33mor a single float to set both timeouts to the same value.#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m ) #x1B[94melif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(timeout, TimeoutSauce): #x1B[94mpass#x1B[39;49;00m #x1B[94melse#x1B[39;49;00m: timeout = TimeoutSauce(connect=timeout, read=timeout) #x1B[94mtry#x1B[39;49;00m: #x1B[94mif#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m chunked: > resp = conn.urlopen( method=request.method, url=url, body=request.body, headers=request.headers, redirect=#x1B[94mFalse#x1B[39;49;00m, assert_same_host=#x1B[94mFalse#x1B[39;49;00m, preload_content=#x1B[94mFalse#x1B[39;49;00m, decode_content=#x1B[94mFalse#x1B[39;49;00m, retries=#x1B[96mself#x1B[39;49;00m.max_retries, timeout=timeout, ) #x1B[1m#x1B[31mrequests/adapters.py#x1B[0m:489: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <urllib3.connectionpool.HTTPConnectionPool object at 0x7f5e3466a740>, method = 'GET', url = '/', body = None headers = {'User-Agent': 'python-requests/2.28.0', 'Accept-Encoding': 'gzip, deflate, br', 'Accept': '*/*', 'Connection': 'keep-alive'} retries = Retry(total=0, connect=None, read=False, redirect=None, status=None), redirect = False, assert_same_host = False timeout = Timeout(connect=0.1, read=0.1, total=None), pool_timeout = None, release_conn = False, chunked = False body_pos = None, response_kw = {'decode_content': False, 'preload_content': False} parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/', query=None, fragment=None) destination_scheme = None, conn = None, release_this_conn = True, http_tunnel_required = False, err = None clean_exit = False #x1B[94mdef#x1B[39;49;00m #x1B[92murlopen#x1B[39;49;00m( #x1B[96mself#x1B[39;49;00m, method, url, body=#x1B[94mNone#x1B[39;49;00m, headers=#x1B[94mNone#x1B[39;49;00m, retries=#x1B[94mNone#x1B[39;49;00m, redirect=#x1B[94mTrue#x1B[39;49;00m, assert_same_host=#x1B[94mTrue#x1B[39;49;00m, timeout=_Default, pool_timeout=#x1B[94mNone#x1B[39;49;00m, release_conn=#x1B[94mNone#x1B[39;49;00m, chunked=#x1B[94mFalse#x1B[39;49;00m, body_pos=#x1B[94mNone#x1B[39;49;00m, **response_kw ): #x1B[33m"""#x1B[39;49;00m #x1B[33m Get a connection from the pool and perform an HTTP request. This is the#x1B[39;49;00m #x1B[33m lowest level call for making a request, so you'll need to specify all#x1B[39;49;00m #x1B[33m the raw details.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m .. note::#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m More commonly, it's appropriate to use a convenience method provided#x1B[39;49;00m #x1B[33m by :class:`.RequestMethods`, such as :meth:`request`.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m .. note::#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m `release_conn` will only behave as expected if#x1B[39;49;00m #x1B[33m `preload_content=False` because we want to make#x1B[39;49;00m #x1B[33m `preload_content=False` the default behaviour someday soon without#x1B[39;49;00m #x1B[33m breaking backwards compatibility.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param method:#x1B[39;49;00m #x1B[33m HTTP request method (such as GET, POST, PUT, etc.)#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param url:#x1B[39;49;00m #x1B[33m The URL to perform the request on.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param body:#x1B[39;49;00m #x1B[33m Data to send in the request body, either :class:`str`, :class:`bytes`,#x1B[39;49;00m #x1B[33m an iterable of :class:`str`/:class:`bytes`, or a file-like object.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param headers:#x1B[39;49;00m #x1B[33m Dictionary of custom headers to send, such as User-Agent,#x1B[39;49;00m #x1B[33m If-None-Match, etc. If None, pool headers are used. If provided,#x1B[39;49;00m #x1B[33m these headers completely replace any pool-specific headers.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param retries:#x1B[39;49;00m #x1B[33m Configure the number of retries to allow before raising a#x1B[39;49;00m #x1B[33m :class:`~urllib3.exceptions.MaxRetryError` exception.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m Pass ``None`` to retry until you receive a response. Pass a#x1B[39;49;00m #x1B[33m :class:`~urllib3.util.retry.Retry` object for fine-grained control#x1B[39;49;00m #x1B[33m over different types of retries.#x1B[39;49;00m #x1B[33m Pass an integer number to retry connection errors that many times,#x1B[39;49;00m #x1B[33m but no other types of errors. Pass zero to never retry.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m If ``False``, then retries are disabled and any exception is raised#x1B[39;49;00m #x1B[33m immediately. Also, instead of raising a MaxRetryError on redirects,#x1B[39;49;00m #x1B[33m the redirect response will be returned.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param redirect:#x1B[39;49;00m #x1B[33m If True, automatically handle redirects (status codes 301, 302,#x1B[39;49;00m #x1B[33m 303, 307, 308). Each redirect counts as a retry. Disabling retries#x1B[39;49;00m #x1B[33m will disable redirect, too.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param assert_same_host:#x1B[39;49;00m #x1B[33m If ``True``, will make sure that the host of the pool requests is#x1B[39;49;00m #x1B[33m consistent else will raise HostChangedError. When ``False``, you can#x1B[39;49;00m #x1B[33m use the pool on an HTTP proxy and request foreign hosts.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param timeout:#x1B[39;49;00m #x1B[33m If specified, overrides the default timeout for this one#x1B[39;49;00m #x1B[33m request. It may be a float (in seconds) or an instance of#x1B[39;49;00m #x1B[33m :class:`urllib3.util.Timeout`.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param pool_timeout:#x1B[39;49;00m #x1B[33m If set and the pool is set to block=True, then this method will#x1B[39;49;00m #x1B[33m block for ``pool_timeout`` seconds and raise EmptyPoolError if no#x1B[39;49;00m #x1B[33m connection is available within the time period.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param release_conn:#x1B[39;49;00m #x1B[33m If False, then the urlopen call will not release the connection#x1B[39;49;00m #x1B[33m back into the pool once a response is received (but will release if#x1B[39;49;00m #x1B[33m you read the entire contents of the response such as when#x1B[39;49;00m #x1B[33m `preload_content=True`). This is useful if you're not preloading#x1B[39;49;00m #x1B[33m the response's content immediately. You will need to call#x1B[39;49;00m #x1B[33m ``r.release_conn()`` on the response ``r`` to return the connection#x1B[39;49;00m #x1B[33m back into the pool. If None, it takes the value of#x1B[39;49;00m #x1B[33m ``response_kw.get('preload_content', True)``.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param chunked:#x1B[39;49;00m #x1B[33m If True, urllib3 will send the body using chunked transfer#x1B[39;49;00m #x1B[33m encoding. Otherwise, urllib3 will send the body using the standard#x1B[39;49;00m #x1B[33m content-length form. Defaults to False.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param int body_pos:#x1B[39;49;00m #x1B[33m Position to seek to in file-like body in the event of a retry or#x1B[39;49;00m #x1B[33m redirect. Typically this won't need to be set because urllib3 will#x1B[39;49;00m #x1B[33m auto-populate the value when needed.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param \\**response_kw:#x1B[39;49;00m #x1B[33m Additional parameters are passed to#x1B[39;49;00m #x1B[33m :meth:`urllib3.response.HTTPResponse.from_httplib`#x1B[39;49;00m #x1B[33m """#x1B[39;49;00m parsed_url = parse_url(url) destination_scheme = parsed_url.scheme #x1B[94mif#x1B[39;49;00m headers #x1B[95mis#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m: headers = #x1B[96mself#x1B[39;49;00m.headers #x1B[94mif#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(retries, Retry): retries = Retry.from_int(retries, redirect=redirect, default=#x1B[96mself#x1B[39;49;00m.retries) #x1B[94mif#x1B[39;49;00m release_conn #x1B[95mis#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m: release_conn = response_kw.get(#x1B[33m"#x1B[39;49;00m#x1B[33mpreload_content#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[94mTrue#x1B[39;49;00m) #x1B[90m# Check host#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m assert_same_host #x1B[95mand#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.is_same_host(url): #x1B[94mraise#x1B[39;49;00m HostChangedError(#x1B[96mself#x1B[39;49;00m, url, retries) #x1B[90m# Ensure that the URL we're connecting to is properly encoded#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m url.startswith(#x1B[33m"#x1B[39;49;00m#x1B[33m/#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m): url = six.ensure_str(_encode_target(url)) #x1B[94melse#x1B[39;49;00m: url = six.ensure_str(parsed_url.url) conn = #x1B[94mNone#x1B[39;49;00m #x1B[90m# Track whether `conn` needs to be released before#x1B[39;49;00m #x1B[90m# returning/raising/recursing. Update this variable if necessary, and#x1B[39;49;00m #x1B[90m# leave `release_conn` constant throughout the function. That way, if#x1B[39;49;00m #x1B[90m# the function recurses, the original value of `release_conn` will be#x1B[39;49;00m #x1B[90m# passed down into the recursive call, and its value will be respected.#x1B[39;49;00m #x1B[90m##x1B[39;49;00m #x1B[90m# See issue #651 [1] for details.#x1B[39;49;00m #x1B[90m##x1B[39;49;00m #x1B[90m# [1] <https://github.com/urllib3/urllib3/issues/651>#x1B[39;49;00m release_this_conn = release_conn http_tunnel_required = connection_requires_http_tunnel( #x1B[96mself#x1B[39;49;00m.proxy, #x1B[96mself#x1B[39;49;00m.proxy_config, destination_scheme ) #x1B[90m# Merge the proxy headers. Only done when not using HTTP CONNECT. We#x1B[39;49;00m #x1B[90m# have to copy the headers dict so we can safely change it without those#x1B[39;49;00m #x1B[90m# changes being reflected in anyone else's copy.#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m http_tunnel_required: headers = headers.copy() headers.update(#x1B[96mself#x1B[39;49;00m.proxy_headers) #x1B[90m# Must keep the exception bound to a separate variable or else Python 3#x1B[39;49;00m #x1B[90m# complains about UnboundLocalError.#x1B[39;49;00m err = #x1B[94mNone#x1B[39;49;00m #x1B[90m# Keep track of whether we cleanly exited the except block. This#x1B[39;49;00m #x1B[90m# ensures we do proper cleanup in finally.#x1B[39;49;00m clean_exit = #x1B[94mFalse#x1B[39;49;00m #x1B[90m# Rewind body position, if needed. Record current position#x1B[39;49;00m #x1B[90m# for future rewinds in the event of a redirect/retry.#x1B[39;49;00m body_pos = set_file_position(body, body_pos) #x1B[94mtry#x1B[39;49;00m: #x1B[90m# Request a connection from the queue.#x1B[39;49;00m timeout_obj = #x1B[96mself#x1B[39;49;00m._get_timeout(timeout) conn = #x1B[96mself#x1B[39;49;00m._get_conn(timeout=pool_timeout) conn.timeout = timeout_obj.connect_timeout is_new_proxy_conn = #x1B[96mself#x1B[39;49;00m.proxy #x1B[95mis#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m #x1B[95mand#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[96mgetattr#x1B[39;49;00m( conn, #x1B[33m"#x1B[39;49;00m#x1B[33msock#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[94mNone#x1B[39;49;00m ) #x1B[94mif#x1B[39;49;00m is_new_proxy_conn #x1B[95mand#x1B[39;49;00m http_tunnel_required: #x1B[96mself#x1B[39;49;00m._prepare_proxy(conn) #x1B[90m# Make the request on the httplib connection object.#x1B[39;49;00m httplib_response = #x1B[96mself#x1B[39;49;00m._make_request( conn, method, url, timeout=timeout_obj, body=body, headers=headers, chunked=chunked, ) #x1B[90m# If we're going to release the connection in ``finally:``, then#x1B[39;49;00m #x1B[90m# the response doesn't need to know about the connection. Otherwise#x1B[39;49;00m #x1B[90m# it will also try to release it and we'll have a double-release#x1B[39;49;00m #x1B[90m# mess.#x1B[39;49;00m response_conn = conn #x1B[94mif#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m release_conn #x1B[94melse#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m #x1B[90m# Pass method to Response for length checking#x1B[39;49;00m response_kw[#x1B[33m"#x1B[39;49;00m#x1B[33mrequest_method#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m] = method #x1B[90m# Import httplib's response into our own wrapper object#x1B[39;49;00m response = #x1B[96mself#x1B[39;49;00m.ResponseCls.from_httplib( httplib_response, pool=#x1B[96mself#x1B[39;49;00m, connection=response_conn, retries=retries, **response_kw ) #x1B[90m# Everything went great!#x1B[39;49;00m clean_exit = #x1B[94mTrue#x1B[39;49;00m #x1B[94mexcept#x1B[39;49;00m EmptyPoolError: #x1B[90m# Didn't get a connection from the pool, no need to clean up#x1B[39;49;00m clean_exit = #x1B[94mTrue#x1B[39;49;00m release_this_conn = #x1B[94mFalse#x1B[39;49;00m #x1B[94mraise#x1B[39;49;00m #x1B[94mexcept#x1B[39;49;00m ( #x1B[96mTimeoutError#x1B[39;49;00m, HTTPException, SocketError, ProtocolError, BaseSSLError, SSLError, CertificateError, ) #x1B[94mas#x1B[39;49;00m e: #x1B[90m# Discard the connection for these exceptions. It will be#x1B[39;49;00m #x1B[90m# replaced during the next _get_conn() call.#x1B[39;49;00m clean_exit = #x1B[94mFalse#x1B[39;49;00m #x1B[94mdef#x1B[39;49;00m #x1B[92m_is_ssl_error_message_from_http_proxy#x1B[39;49;00m(ssl_error): #x1B[90m# We're trying to detect the message 'WRONG_VERSION_NUMBER' but#x1B[39;49;00m #x1B[90m# SSLErrors are kinda all over the place when it comes to the message,#x1B[39;49;00m #x1B[90m# so we try to cover our bases here!#x1B[39;49;00m message = #x1B[33m"#x1B[39;49;00m#x1B[33m #x1B[39;49;00m#x1B[33m"#x1B[39;49;00m.join(re.split(#x1B[33m"#x1B[39;49;00m#x1B[33m[^a-z]#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[96mstr#x1B[39;49;00m(ssl_error).lower())) #x1B[94mreturn#x1B[39;49;00m ( #x1B[33m"#x1B[39;49;00m#x1B[33mwrong version number#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[95min#x1B[39;49;00m message #x1B[95mor#x1B[39;49;00m #x1B[33m"#x1B[39;49;00m#x1B[33munknown protocol#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[95min#x1B[39;49;00m message ) #x1B[90m# Try to detect a common user error with proxies which is to#x1B[39;49;00m #x1B[90m# set an HTTP proxy to be HTTPS when it should be 'http://'#x1B[39;49;00m #x1B[90m# (ie {'http': 'http://proxy', 'https': 'https://proxy'})#x1B[39;49;00m #x1B[90m# Instead we add a nice error message and point to a URL.#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m ( #x1B[96misinstance#x1B[39;49;00m(e, BaseSSLError) #x1B[95mand#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.proxy #x1B[95mand#x1B[39;49;00m _is_ssl_error_message_from_http_proxy(e) ): e = ProxyError( #x1B[33m"#x1B[39;49;00m#x1B[33mYour proxy appears to only use HTTP and not HTTPS, #x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[33m"#x1B[39;49;00m#x1B[33mtry changing your proxy URL to be HTTP. See: #x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[33m"#x1B[39;49;00m#x1B[33mhttps://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[33m"#x1B[39;49;00m#x1B[33m#https-proxy-error-http-proxy#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, SSLError(e), ) #x1B[94melif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(e, (BaseSSLError, CertificateError)): e = SSLError(e) #x1B[94melif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(e, (SocketError, NewConnectionError)) #x1B[95mand#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.proxy: e = ProxyError(#x1B[33m"#x1B[39;49;00m#x1B[33mCannot connect to proxy.#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, e) #x1B[94melif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(e, (SocketError, HTTPException)): e = ProtocolError(#x1B[33m"#x1B[39;49;00m#x1B[33mConnection aborted.#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, e) > retries = retries.increment( method, url, error=e, _pool=#x1B[96mself#x1B[39;49;00m, _stacktrace=sys.exc_info()[#x1B[94m2#x1B[39;49;00m] ) #x1B[1m#x1B[31m/usr/lib/python3/dist-packages/urllib3/connectionpool.py#x1B[0m:785: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = Retry(total=0, connect=None, read=False, redirect=None, status=None), method = 'GET', url = '/', response = None error = ReadTimeoutError("HTTPConnectionPool(host='10.255.255.1', port=80): Read timed out. (read timeout=0.1)") _pool = <urllib3.connectionpool.HTTPConnectionPool object at 0x7f5e3466a740> _stacktrace = <traceback object at 0x7f5e368fa040> #x1B[94mdef#x1B[39;49;00m #x1B[92mincrement#x1B[39;49;00m( #x1B[96mself#x1B[39;49;00m, method=#x1B[94mNone#x1B[39;49;00m, url=#x1B[94mNone#x1B[39;49;00m, response=#x1B[94mNone#x1B[39;49;00m, error=#x1B[94mNone#x1B[39;49;00m, _pool=#x1B[94mNone#x1B[39;49;00m, _stacktrace=#x1B[94mNone#x1B[39;49;00m, ): #x1B[33m"""Return a new Retry object with incremented retry counters.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param response: A response object, or None, if the server did not#x1B[39;49;00m #x1B[33m return a response.#x1B[39;49;00m #x1B[33m :type response: :class:`~urllib3.response.HTTPResponse`#x1B[39;49;00m #x1B[33m :param Exception error: An error encountered during the request, or#x1B[39;49;00m #x1B[33m None if the response was received successfully.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :return: A new ``Retry`` object.#x1B[39;49;00m #x1B[33m """#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.total #x1B[95mis#x1B[39;49;00m #x1B[94mFalse#x1B[39;49;00m #x1B[95mand#x1B[39;49;00m error: #x1B[90m# Disabled, indicate to re-raise the error.#x1B[39;49;00m #x1B[94mraise#x1B[39;49;00m six.reraise(#x1B[96mtype#x1B[39;49;00m(error), error, _stacktrace) total = #x1B[96mself#x1B[39;49;00m.total #x1B[94mif#x1B[39;49;00m total #x1B[95mis#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m: total -= #x1B[94m1#x1B[39;49;00m connect = #x1B[96mself#x1B[39;49;00m.connect read = #x1B[96mself#x1B[39;49;00m.read redirect = #x1B[96mself#x1B[39;49;00m.redirect status_count = #x1B[96mself#x1B[39;49;00m.status other = #x1B[96mself#x1B[39;49;00m.other cause = #x1B[33m"#x1B[39;49;00m#x1B[33munknown#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m status = #x1B[94mNone#x1B[39;49;00m redirect_location = #x1B[94mNone#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m error #x1B[95mand#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m._is_connection_error(error): #x1B[90m# Connect retry?#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m connect #x1B[95mis#x1B[39;49;00m #x1B[94mFalse#x1B[39;49;00m: #x1B[94mraise#x1B[39;49;00m six.reraise(#x1B[96mtype#x1B[39;49;00m(error), error, _stacktrace) #x1B[94melif#x1B[39;49;00m connect #x1B[95mis#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m: connect -= #x1B[94m1#x1B[39;49;00m #x1B[94melif#x1B[39;49;00m error #x1B[95mand#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m._is_read_error(error): #x1B[90m# Read retry?#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m read #x1B[95mis#x1B[39;49;00m #x1B[94mFalse#x1B[39;49;00m #x1B[95mor#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m._is_method_retryable(method): > #x1B[94mraise#x1B[39;49;00m six.reraise(#x1B[96mtype#x1B[39;49;00m(error), error, _stacktrace) #x1B[1m#x1B[31m/usr/lib/python3/dist-packages/urllib3/util/retry.py#x1B[0m:550: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tp = <class 'urllib3.exceptions.ReadTimeoutError'>, value = None, tb = None #x1B[94mdef#x1B[39;49;00m #x1B[92mreraise#x1B[39;49;00m(tp, value, tb=#x1B[94mNone#x1B[39;49;00m): #x1B[94mtry#x1B[39;49;00m: #x1B[94mif#x1B[39;49;00m value #x1B[95mis#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m: value = tp() #x1B[94mif#x1B[39;49;00m value.__traceback__ #x1B[95mis#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m tb: #x1B[94mraise#x1B[39;49;00m value.with_traceback(tb) > #x1B[94mraise#x1B[39;49;00m value #x1B[1m#x1B[31m/usr/lib/python3/dist-packages/urllib3/packages/six.py#x1B[0m:770: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <urllib3.connectionpool.HTTPConnectionPool object at 0x7f5e3466a740>, method = 'GET', url = '/', body = None headers = {'User-Agent': 'python-requests/2.28.0', 'Accept-Encoding': 'gzip, deflate, br', 'Accept': '*/*', 'Connection': 'keep-alive'} retries = Retry(total=0, connect=None, read=False, redirect=None, status=None), redirect = False, assert_same_host = False timeout = Timeout(connect=0.1, read=0.1, total=None), pool_timeout = None, release_conn = False, chunked = False body_pos = None, response_kw = {'decode_content': False, 'preload_content': False} parsed_url = Url(scheme=None, auth=None, host=None, port=None, path='/', query=None, fragment=None) destination_scheme = None, conn = None, release_this_conn = True, http_tunnel_required = False, err = None clean_exit = False #x1B[94mdef#x1B[39;49;00m #x1B[92murlopen#x1B[39;49;00m( #x1B[96mself#x1B[39;49;00m, method, url, body=#x1B[94mNone#x1B[39;49;00m, headers=#x1B[94mNone#x1B[39;49;00m, retries=#x1B[94mNone#x1B[39;49;00m, redirect=#x1B[94mTrue#x1B[39;49;00m, assert_same_host=#x1B[94mTrue#x1B[39;49;00m, timeout=_Default, pool_timeout=#x1B[94mNone#x1B[39;49;00m, release_conn=#x1B[94mNone#x1B[39;49;00m, chunked=#x1B[94mFalse#x1B[39;49;00m, body_pos=#x1B[94mNone#x1B[39;49;00m, **response_kw ): #x1B[33m"""#x1B[39;49;00m #x1B[33m Get a connection from the pool and perform an HTTP request. This is the#x1B[39;49;00m #x1B[33m lowest level call for making a request, so you'll need to specify all#x1B[39;49;00m #x1B[33m the raw details.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m .. note::#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m More commonly, it's appropriate to use a convenience method provided#x1B[39;49;00m #x1B[33m by :class:`.RequestMethods`, such as :meth:`request`.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m .. note::#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m `release_conn` will only behave as expected if#x1B[39;49;00m #x1B[33m `preload_content=False` because we want to make#x1B[39;49;00m #x1B[33m `preload_content=False` the default behaviour someday soon without#x1B[39;49;00m #x1B[33m breaking backwards compatibility.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param method:#x1B[39;49;00m #x1B[33m HTTP request method (such as GET, POST, PUT, etc.)#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param url:#x1B[39;49;00m #x1B[33m The URL to perform the request on.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param body:#x1B[39;49;00m #x1B[33m Data to send in the request body, either :class:`str`, :class:`bytes`,#x1B[39;49;00m #x1B[33m an iterable of :class:`str`/:class:`bytes`, or a file-like object.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param headers:#x1B[39;49;00m #x1B[33m Dictionary of custom headers to send, such as User-Agent,#x1B[39;49;00m #x1B[33m If-None-Match, etc. If None, pool headers are used. If provided,#x1B[39;49;00m #x1B[33m these headers completely replace any pool-specific headers.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param retries:#x1B[39;49;00m #x1B[33m Configure the number of retries to allow before raising a#x1B[39;49;00m #x1B[33m :class:`~urllib3.exceptions.MaxRetryError` exception.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m Pass ``None`` to retry until you receive a response. Pass a#x1B[39;49;00m #x1B[33m :class:`~urllib3.util.retry.Retry` object for fine-grained control#x1B[39;49;00m #x1B[33m over different types of retries.#x1B[39;49;00m #x1B[33m Pass an integer number to retry connection errors that many times,#x1B[39;49;00m #x1B[33m but no other types of errors. Pass zero to never retry.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m If ``False``, then retries are disabled and any exception is raised#x1B[39;49;00m #x1B[33m immediately. Also, instead of raising a MaxRetryError on redirects,#x1B[39;49;00m #x1B[33m the redirect response will be returned.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param redirect:#x1B[39;49;00m #x1B[33m If True, automatically handle redirects (status codes 301, 302,#x1B[39;49;00m #x1B[33m 303, 307, 308). Each redirect counts as a retry. Disabling retries#x1B[39;49;00m #x1B[33m will disable redirect, too.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param assert_same_host:#x1B[39;49;00m #x1B[33m If ``True``, will make sure that the host of the pool requests is#x1B[39;49;00m #x1B[33m consistent else will raise HostChangedError. When ``False``, you can#x1B[39;49;00m #x1B[33m use the pool on an HTTP proxy and request foreign hosts.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param timeout:#x1B[39;49;00m #x1B[33m If specified, overrides the default timeout for this one#x1B[39;49;00m #x1B[33m request. It may be a float (in seconds) or an instance of#x1B[39;49;00m #x1B[33m :class:`urllib3.util.Timeout`.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param pool_timeout:#x1B[39;49;00m #x1B[33m If set and the pool is set to block=True, then this method will#x1B[39;49;00m #x1B[33m block for ``pool_timeout`` seconds and raise EmptyPoolError if no#x1B[39;49;00m #x1B[33m connection is available within the time period.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param release_conn:#x1B[39;49;00m #x1B[33m If False, then the urlopen call will not release the connection#x1B[39;49;00m #x1B[33m back into the pool once a response is received (but will release if#x1B[39;49;00m #x1B[33m you read the entire contents of the response such as when#x1B[39;49;00m #x1B[33m `preload_content=True`). This is useful if you're not preloading#x1B[39;49;00m #x1B[33m the response's content immediately. You will need to call#x1B[39;49;00m #x1B[33m ``r.release_conn()`` on the response ``r`` to return the connection#x1B[39;49;00m #x1B[33m back into the pool. If None, it takes the value of#x1B[39;49;00m #x1B[33m ``response_kw.get('preload_content', True)``.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param chunked:#x1B[39;49;00m #x1B[33m If True, urllib3 will send the body using chunked transfer#x1B[39;49;00m #x1B[33m encoding. Otherwise, urllib3 will send the body using the standard#x1B[39;49;00m #x1B[33m content-length form. Defaults to False.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param int body_pos:#x1B[39;49;00m #x1B[33m Position to seek to in file-like body in the event of a retry or#x1B[39;49;00m #x1B[33m redirect. Typically this won't need to be set because urllib3 will#x1B[39;49;00m #x1B[33m auto-populate the value when needed.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param \\**response_kw:#x1B[39;49;00m #x1B[33m Additional parameters are passed to#x1B[39;49;00m #x1B[33m :meth:`urllib3.response.HTTPResponse.from_httplib`#x1B[39;49;00m #x1B[33m """#x1B[39;49;00m parsed_url = parse_url(url) destination_scheme = parsed_url.scheme #x1B[94mif#x1B[39;49;00m headers #x1B[95mis#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m: headers = #x1B[96mself#x1B[39;49;00m.headers #x1B[94mif#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(retries, Retry): retries = Retry.from_int(retries, redirect=redirect, default=#x1B[96mself#x1B[39;49;00m.retries) #x1B[94mif#x1B[39;49;00m release_conn #x1B[95mis#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m: release_conn = response_kw.get(#x1B[33m"#x1B[39;49;00m#x1B[33mpreload_content#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[94mTrue#x1B[39;49;00m) #x1B[90m# Check host#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m assert_same_host #x1B[95mand#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.is_same_host(url): #x1B[94mraise#x1B[39;49;00m HostChangedError(#x1B[96mself#x1B[39;49;00m, url, retries) #x1B[90m# Ensure that the URL we're connecting to is properly encoded#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m url.startswith(#x1B[33m"#x1B[39;49;00m#x1B[33m/#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m): url = six.ensure_str(_encode_target(url)) #x1B[94melse#x1B[39;49;00m: url = six.ensure_str(parsed_url.url) conn = #x1B[94mNone#x1B[39;49;00m #x1B[90m# Track whether `conn` needs to be released before#x1B[39;49;00m #x1B[90m# returning/raising/recursing. Update this variable if necessary, and#x1B[39;49;00m #x1B[90m# leave `release_conn` constant throughout the function. That way, if#x1B[39;49;00m #x1B[90m# the function recurses, the original value of `release_conn` will be#x1B[39;49;00m #x1B[90m# passed down into the recursive call, and its value will be respected.#x1B[39;49;00m #x1B[90m##x1B[39;49;00m #x1B[90m# See issue #651 [1] for details.#x1B[39;49;00m #x1B[90m##x1B[39;49;00m #x1B[90m# [1] <https://github.com/urllib3/urllib3/issues/651>#x1B[39;49;00m release_this_conn = release_conn http_tunnel_required = connection_requires_http_tunnel( #x1B[96mself#x1B[39;49;00m.proxy, #x1B[96mself#x1B[39;49;00m.proxy_config, destination_scheme ) #x1B[90m# Merge the proxy headers. Only done when not using HTTP CONNECT. We#x1B[39;49;00m #x1B[90m# have to copy the headers dict so we can safely change it without those#x1B[39;49;00m #x1B[90m# changes being reflected in anyone else's copy.#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m http_tunnel_required: headers = headers.copy() headers.update(#x1B[96mself#x1B[39;49;00m.proxy_headers) #x1B[90m# Must keep the exception bound to a separate variable or else Python 3#x1B[39;49;00m #x1B[90m# complains about UnboundLocalError.#x1B[39;49;00m err = #x1B[94mNone#x1B[39;49;00m #x1B[90m# Keep track of whether we cleanly exited the except block. This#x1B[39;49;00m #x1B[90m# ensures we do proper cleanup in finally.#x1B[39;49;00m clean_exit = #x1B[94mFalse#x1B[39;49;00m #x1B[90m# Rewind body position, if needed. Record current position#x1B[39;49;00m #x1B[90m# for future rewinds in the event of a redirect/retry.#x1B[39;49;00m body_pos = set_file_position(body, body_pos) #x1B[94mtry#x1B[39;49;00m: #x1B[90m# Request a connection from the queue.#x1B[39;49;00m timeout_obj = #x1B[96mself#x1B[39;49;00m._get_timeout(timeout) conn = #x1B[96mself#x1B[39;49;00m._get_conn(timeout=pool_timeout) conn.timeout = timeout_obj.connect_timeout is_new_proxy_conn = #x1B[96mself#x1B[39;49;00m.proxy #x1B[95mis#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m #x1B[95mand#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[96mgetattr#x1B[39;49;00m( conn, #x1B[33m"#x1B[39;49;00m#x1B[33msock#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[94mNone#x1B[39;49;00m ) #x1B[94mif#x1B[39;49;00m is_new_proxy_conn #x1B[95mand#x1B[39;49;00m http_tunnel_required: #x1B[96mself#x1B[39;49;00m._prepare_proxy(conn) #x1B[90m# Make the request on the httplib connection object.#x1B[39;49;00m > httplib_response = #x1B[96mself#x1B[39;49;00m._make_request( conn, method, url, timeout=timeout_obj, body=body, headers=headers, chunked=chunked, ) #x1B[1m#x1B[31m/usr/lib/python3/dist-packages/urllib3/connectionpool.py#x1B[0m:703: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <urllib3.connectionpool.HTTPConnectionPool object at 0x7f5e3466a740> conn = <urllib3.connection.HTTPConnection object at 0x7f5e3466a380>, method = 'GET', url = '/' timeout = Timeout(connect=0.1, read=0.1, total=None), chunked = False httplib_request_kw = {'body': None, 'headers': {'User-Agent': 'python-requests/2.28.0', 'Accept-Encoding': 'gzip, deflate, br', 'Accept': '*/*', 'Connection': 'keep-alive'}} timeout_obj = Timeout(connect=0.1, read=0.1, total=None), read_timeout = 0.1 #x1B[94mdef#x1B[39;49;00m #x1B[92m_make_request#x1B[39;49;00m( #x1B[96mself#x1B[39;49;00m, conn, method, url, timeout=_Default, chunked=#x1B[94mFalse#x1B[39;49;00m, **httplib_request_kw ): #x1B[33m"""#x1B[39;49;00m #x1B[33m Perform a request on a given urllib connection object taken from our#x1B[39;49;00m #x1B[33m pool.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param conn:#x1B[39;49;00m #x1B[33m a connection from one of our connection pools#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param timeout:#x1B[39;49;00m #x1B[33m Socket timeout in seconds for the request. This can be a#x1B[39;49;00m #x1B[33m float or integer, which will set the same timeout value for#x1B[39;49;00m #x1B[33m the socket connect and the socket read, or an instance of#x1B[39;49;00m #x1B[33m :class:`urllib3.util.Timeout`, which gives you more fine-grained#x1B[39;49;00m #x1B[33m control over your timeouts.#x1B[39;49;00m #x1B[33m """#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m.num_requests += #x1B[94m1#x1B[39;49;00m timeout_obj = #x1B[96mself#x1B[39;49;00m._get_timeout(timeout) timeout_obj.start_connect() conn.timeout = timeout_obj.connect_timeout #x1B[90m# Trigger any extra validation we need to do.#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: #x1B[96mself#x1B[39;49;00m._validate_conn(conn) #x1B[94mexcept#x1B[39;49;00m (SocketTimeout, BaseSSLError) #x1B[94mas#x1B[39;49;00m e: #x1B[90m# Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout.#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m._raise_timeout(err=e, url=url, timeout_value=conn.timeout) #x1B[94mraise#x1B[39;49;00m #x1B[90m# conn.request() calls http.client.*.request, not the method in#x1B[39;49;00m #x1B[90m# urllib3.request. It also calls makefile (recv) on the socket.#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: #x1B[94mif#x1B[39;49;00m chunked: conn.request_chunked(method, url, **httplib_request_kw) #x1B[94melse#x1B[39;49;00m: conn.request(method, url, **httplib_request_kw) #x1B[90m# We are swallowing BrokenPipeError (errno.EPIPE) since the server is#x1B[39;49;00m #x1B[90m# legitimately able to close the connection after sending a valid response.#x1B[39;49;00m #x1B[90m# With this behaviour, the received response is still readable.#x1B[39;49;00m #x1B[94mexcept#x1B[39;49;00m #x1B[96mBrokenPipeError#x1B[39;49;00m: #x1B[90m# Python 3#x1B[39;49;00m #x1B[94mpass#x1B[39;49;00m #x1B[94mexcept#x1B[39;49;00m #x1B[96mIOError#x1B[39;49;00m #x1B[94mas#x1B[39;49;00m e: #x1B[90m# Python 2 and macOS/Linux#x1B[39;49;00m #x1B[90m# EPIPE and ESHUTDOWN are BrokenPipeError on Python 2, and EPROTOTYPE is needed on macOS#x1B[39;49;00m #x1B[90m# https://erickt.github.io/blog/2014/11/19/adventures-in-debugging-a-potential-osx-kernel-bug/#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m e.errno #x1B[95mnot#x1B[39;49;00m #x1B[95min#x1B[39;49;00m { errno.EPIPE, errno.ESHUTDOWN, errno.EPROTOTYPE, }: #x1B[94mraise#x1B[39;49;00m #x1B[90m# Reset the timeout for the recv() on the socket#x1B[39;49;00m read_timeout = timeout_obj.read_timeout #x1B[90m# App Engine doesn't have a sock attr#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m #x1B[96mgetattr#x1B[39;49;00m(conn, #x1B[33m"#x1B[39;49;00m#x1B[33msock#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[94mNone#x1B[39;49;00m): #x1B[90m# In Python 3 socket.py will catch EAGAIN and return None when you#x1B[39;49;00m #x1B[90m# try and read into the file pointer created by http.client, which#x1B[39;49;00m #x1B[90m# instead raises a BadStatusLine exception. Instead of catching#x1B[39;49;00m #x1B[90m# the exception and assuming all BadStatusLine exceptions are read#x1B[39;49;00m #x1B[90m# timeouts, check for a zero timeout before making the request.#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m read_timeout == #x1B[94m0#x1B[39;49;00m: #x1B[94mraise#x1B[39;49;00m ReadTimeoutError( #x1B[96mself#x1B[39;49;00m, url, #x1B[33m"#x1B[39;49;00m#x1B[33mRead timed out. (read timeout=#x1B[39;49;00m#x1B[33m%s#x1B[39;49;00m#x1B[33m)#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m % read_timeout ) #x1B[94mif#x1B[39;49;00m read_timeout #x1B[95mis#x1B[39;49;00m Timeout.DEFAULT_TIMEOUT: conn.sock.settimeout(socket.getdefaulttimeout()) #x1B[94melse#x1B[39;49;00m: #x1B[90m# None or a value#x1B[39;49;00m conn.sock.settimeout(read_timeout) #x1B[90m# Receive the response from the server#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: #x1B[94mtry#x1B[39;49;00m: #x1B[90m# Python 2.7, use buffering of HTTP responses#x1B[39;49;00m httplib_response = conn.getresponse(buffering=#x1B[94mTrue#x1B[39;49;00m) #x1B[94mexcept#x1B[39;49;00m #x1B[96mTypeError#x1B[39;49;00m: #x1B[90m# Python 3#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: httplib_response = conn.getresponse() #x1B[94mexcept#x1B[39;49;00m #x1B[96mBaseException#x1B[39;49;00m #x1B[94mas#x1B[39;49;00m e: #x1B[90m# Remove the TypeError from the exception chain in#x1B[39;49;00m #x1B[90m# Python 3 (including for exceptions like SystemExit).#x1B[39;49;00m #x1B[90m# Otherwise it looks like a bug in the code.#x1B[39;49;00m six.raise_from(e, #x1B[94mNone#x1B[39;49;00m) #x1B[94mexcept#x1B[39;49;00m (SocketTimeout, BaseSSLError, SocketError) #x1B[94mas#x1B[39;49;00m e: > #x1B[96mself#x1B[39;49;00m._raise_timeout(err=e, url=url, timeout_value=read_timeout) #x1B[1m#x1B[31m/usr/lib/python3/dist-packages/urllib3/connectionpool.py#x1B[0m:451: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <urllib3.connectionpool.HTTPConnectionPool object at 0x7f5e3466a740>, err = TimeoutError('timed out'), url = '/' timeout_value = 0.1 #x1B[94mdef#x1B[39;49;00m #x1B[92m_raise_timeout#x1B[39;49;00m(#x1B[96mself#x1B[39;49;00m, err, url, timeout_value): #x1B[33m"""Is the error actually a timeout? Will raise a ReadTimeout or pass"""#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(err, SocketTimeout): > #x1B[94mraise#x1B[39;49;00m ReadTimeoutError( #x1B[96mself#x1B[39;49;00m, url, #x1B[33m"#x1B[39;49;00m#x1B[33mRead timed out. (read timeout=#x1B[39;49;00m#x1B[33m%s#x1B[39;49;00m#x1B[33m)#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m % timeout_value ) #x1B[1m#x1B[31mE urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='10.255.255.1', port=80): Read timed out. (read timeout=0.1)#x1B[0m #x1B[1m#x1B[31m/usr/lib/python3/dist-packages/urllib3/connectionpool.py#x1B[0m:340: ReadTimeoutError #x1B[33mDuring handling of the above exception, another exception occurred:#x1B[0m self = <tests.test_requests.TestTimeout object at 0x7f5e368dacb0>, timeout = Timeout(connect=0.1, read=0.1, total=None) #x1B[37m@pytest#x1B[39;49;00m.mark.parametrize( #x1B[33m"#x1B[39;49;00m#x1B[33mtimeout#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, ((#x1B[94m0.1#x1B[39;49;00m, #x1B[94m0.1#x1B[39;49;00m), Urllib3Timeout(connect=#x1B[94m0.1#x1B[39;49;00m, read=#x1B[94m0.1#x1B[39;49;00m)) ) #x1B[94mdef#x1B[39;49;00m #x1B[92mtest_total_timeout_connect#x1B[39;49;00m(#x1B[96mself#x1B[39;49;00m, timeout): #x1B[94mtry#x1B[39;49;00m: > requests.get(TARPIT, timeout=timeout) #x1B[1m#x1B[31mtests/test_requests.py#x1B[0m:2444: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ #x1B[1m#x1B[31mrequests/api.py#x1B[0m:73: in get #x1B[94mreturn#x1B[39;49;00m request(#x1B[33m"#x1B[39;49;00m#x1B[33mget#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, url, params=params, **kwargs) #x1B[1m#x1B[31mrequests/api.py#x1B[0m:59: in request #x1B[94mreturn#x1B[39;49;00m session.request(method=method, url=url, **kwargs) #x1B[1m#x1B[31mrequests/sessions.py#x1B[0m:587: in request resp = #x1B[96mself#x1B[39;49;00m.send(prep, **send_kwargs) #x1B[1m#x1B[31mrequests/sessions.py#x1B[0m:701: in send r = adapter.send(request, **kwargs) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <requests.adapters.HTTPAdapter object at 0x7f5e368d8f10>, request = <PreparedRequest [GET]>, stream = False timeout = Timeout(connect=0.1, read=0.1, total=None), verify = True, cert = None, proxies = OrderedDict() #x1B[94mdef#x1B[39;49;00m #x1B[92msend#x1B[39;49;00m( #x1B[96mself#x1B[39;49;00m, request, stream=#x1B[94mFalse#x1B[39;49;00m, timeout=#x1B[94mNone#x1B[39;49;00m, verify=#x1B[94mTrue#x1B[39;49;00m, cert=#x1B[94mNone#x1B[39;49;00m, proxies=#x1B[94mNone#x1B[39;49;00m ): #x1B[33m"""Sends PreparedRequest object. Returns Response object.#x1B[39;49;00m #x1B[33m#x1B[39;49;00m #x1B[33m :param request: The :class:`PreparedRequest <PreparedRequest>` being sent.#x1B[39;49;00m #x1B[33m :param stream: (optional) Whether to stream the request content.#x1B[39;49;00m #x1B[33m :param timeout: (optional) How long to wait for the server to send#x1B[39;49;00m #x1B[33m data before giving up, as a float, or a :ref:`(connect timeout,#x1B[39;49;00m #x1B[33m read timeout) <timeouts>` tuple.#x1B[39;49;00m #x1B[33m :type timeout: float or tuple or urllib3 Timeout object#x1B[39;49;00m #x1B[33m :param verify: (optional) Either a boolean, in which case it controls whether#x1B[39;49;00m #x1B[33m we verify the server's TLS certificate, or a string, in which case it#x1B[39;49;00m #x1B[33m must be a path to a CA bundle to use#x1B[39;49;00m #x1B[33m :param cert: (optional) Any user-provided SSL certificate to be trusted.#x1B[39;49;00m #x1B[33m :param proxies: (optional) The proxies dictionary to apply to the request.#x1B[39;49;00m #x1B[33m :rtype: requests.Response#x1B[39;49;00m #x1B[33m """#x1B[39;49;00m #x1B[94mtry#x1B[39;49;00m: conn = #x1B[96mself#x1B[39;49;00m.get_connection(request.url, proxies) #x1B[94mexcept#x1B[39;49;00m LocationValueError #x1B[94mas#x1B[39;49;00m e: #x1B[94mraise#x1B[39;49;00m InvalidURL(e, request=request) #x1B[96mself#x1B[39;49;00m.cert_verify(conn, request.url, verify, cert) url = #x1B[96mself#x1B[39;49;00m.request_url(request, proxies) #x1B[96mself#x1B[39;49;00m.add_headers( request, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies, ) chunked = #x1B[95mnot#x1B[39;49;00m (request.body #x1B[95mis#x1B[39;49;00m #x1B[94mNone#x1B[39;49;00m #x1B[95mor#x1B[39;49;00m #x1B[33m"#x1B[39;49;00m#x1B[33mContent-Length#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[95min#x1B[39;49;00m request.headers) #x1B[94mif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(timeout, #x1B[96mtuple#x1B[39;49;00m): #x1B[94mtry#x1B[39;49;00m: connect, read = timeout timeout = TimeoutSauce(connect=connect, read=read) #x1B[94mexcept#x1B[39;49;00m #x1B[96mValueError#x1B[39;49;00m: #x1B[94mraise#x1B[39;49;00m #x1B[96mValueError#x1B[39;49;00m( #x1B[33mf#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33mInvalid timeout #x1B[39;49;00m#x1B[33m{#x1B[39;49;00mtimeout#x1B[33m}#x1B[39;49;00m#x1B[33m. Pass a (connect, read) timeout tuple, #x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[33mf#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33mor a single float to set both timeouts to the same value.#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m ) #x1B[94melif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(timeout, TimeoutSauce): #x1B[94mpass#x1B[39;49;00m #x1B[94melse#x1B[39;49;00m: timeout = TimeoutSauce(connect=timeout, read=timeout) #x1B[94mtry#x1B[39;49;00m: #x1B[94mif#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m chunked: resp = conn.urlopen( method=request.method, url=url, body=request.body, headers=request.headers, redirect=#x1B[94mFalse#x1B[39;49;00m, assert_same_host=#x1B[94mFalse#x1B[39;49;00m, preload_content=#x1B[94mFalse#x1B[39;49;00m, decode_content=#x1B[94mFalse#x1B[39;49;00m, retries=#x1B[96mself#x1B[39;49;00m.max_retries, timeout=timeout, ) #x1B[90m# Send the request.#x1B[39;49;00m #x1B[94melse#x1B[39;49;00m: #x1B[94mif#x1B[39;49;00m #x1B[96mhasattr#x1B[39;49;00m(conn, #x1B[33m"#x1B[39;49;00m#x1B[33mproxy_pool#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m): conn = conn.proxy_pool low_conn = conn._get_conn(timeout=DEFAULT_POOL_TIMEOUT) #x1B[94mtry#x1B[39;49;00m: skip_host = #x1B[33m"#x1B[39;49;00m#x1B[33mHost#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m #x1B[95min#x1B[39;49;00m request.headers low_conn.putrequest( request.method, url, skip_accept_encoding=#x1B[94mTrue#x1B[39;49;00m, skip_host=skip_host, ) #x1B[94mfor#x1B[39;49;00m header, value #x1B[95min#x1B[39;49;00m request.headers.items(): low_conn.putheader(header, value) low_conn.endheaders() #x1B[94mfor#x1B[39;49;00m i #x1B[95min#x1B[39;49;00m request.body: low_conn.send(#x1B[96mhex#x1B[39;49;00m(#x1B[96mlen#x1B[39;49;00m(i))[#x1B[94m2#x1B[39;49;00m:].encode(#x1B[33m"#x1B[39;49;00m#x1B[33mutf-8#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m)) low_conn.send(#x1B[33mb#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33m\r#x1B[39;49;00m#x1B[33m\n#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m) low_conn.send(i) low_conn.send(#x1B[33mb#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33m\r#x1B[39;49;00m#x1B[33m\n#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m) low_conn.send(#x1B[33mb#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33m0#x1B[39;49;00m#x1B[33m\r#x1B[39;49;00m#x1B[33m\n#x1B[39;49;00m#x1B[33m\r#x1B[39;49;00m#x1B[33m\n#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m) #x1B[90m# Receive the response from the server#x1B[39;49;00m r = low_conn.getresponse() resp = HTTPResponse.from_httplib( r, pool=conn, connection=low_conn, preload_content=#x1B[94mFalse#x1B[39;49;00m, decode_content=#x1B[94mFalse#x1B[39;49;00m, ) #x1B[94mexcept#x1B[39;49;00m #x1B[96mException#x1B[39;49;00m: #x1B[90m# If we hit any problems here, clean up the connection.#x1B[39;49;00m #x1B[90m# Then, raise so that we can handle the actual exception.#x1B[39;49;00m low_conn.close() #x1B[94mraise#x1B[39;49;00m #x1B[94mexcept#x1B[39;49;00m (ProtocolError, #x1B[96mOSError#x1B[39;49;00m) #x1B[94mas#x1B[39;49;00m err: #x1B[94mraise#x1B[39;49;00m #x1B[96mConnectionError#x1B[39;49;00m(err, request=request) #x1B[94mexcept#x1B[39;49;00m MaxRetryError #x1B[94mas#x1B[39;49;00m e: #x1B[94mif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(e.reason, ConnectTimeoutError): #x1B[90m# TODO: Remove this in 3.0.0: see #2811#x1B[39;49;00m #x1B[94mif#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(e.reason, NewConnectionError): #x1B[94mraise#x1B[39;49;00m ConnectTimeout(e, request=request) #x1B[94mif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(e.reason, ResponseError): #x1B[94mraise#x1B[39;49;00m RetryError(e, request=request) #x1B[94mif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(e.reason, _ProxyError): #x1B[94mraise#x1B[39;49;00m ProxyError(e, request=request) #x1B[94mif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(e.reason, _SSLError): #x1B[90m# This branch is for urllib3 v1.22 and later.#x1B[39;49;00m #x1B[94mraise#x1B[39;49;00m SSLError(e, request=request) #x1B[94mraise#x1B[39;49;00m #x1B[96mConnectionError#x1B[39;49;00m(e, request=request) #x1B[94mexcept#x1B[39;49;00m ClosedPoolError #x1B[94mas#x1B[39;49;00m e: #x1B[94mraise#x1B[39;49;00m #x1B[96mConnectionError#x1B[39;49;00m(e, request=request) #x1B[94mexcept#x1B[39;49;00m _ProxyError #x1B[94mas#x1B[39;49;00m e: #x1B[94mraise#x1B[39;49;00m ProxyError(e) #x1B[94mexcept#x1B[39;49;00m (_SSLError, _HTTPError) #x1B[94mas#x1B[39;49;00m e: #x1B[94mif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(e, _SSLError): #x1B[90m# This branch is for urllib3 versions earlier than v1.22#x1B[39;49;00m #x1B[94mraise#x1B[39;49;00m SSLError(e, request=request) #x1B[94melif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(e, ReadTimeoutError): > #x1B[94mraise#x1B[39;49;00m ReadTimeout(e, request=request) #x1B[1m#x1B[31mE requests.exceptions.ReadTimeout: HTTPConnectionPool(host='10.255.255.1', port=80): Read timed out. (read timeout=0.1)#x1B[0m #x1B[1m#x1B[31mrequests/adapters.py#x1B[0m:578: ReadTimeout/home/hswong3i/Documents/osc/psf-requests-2.28.0/tests/test_testserver.py:94: this fails non-deterministically under pytest-xdist/home/hswong3i/Documents/osc/psf-requests-2.28.0/tests/test_utils.py:49: condition: cStringIO is None/home/hswong3i/Documents/osc/psf-requests-2.28.0/tests/test_utils.py:814: Test only on Windows/home/hswong3i/Documents/osc/psf-requests-2.28.0/tests/test_utils.py:814: Test only on Windows/home/hswong3i/Documents/osc/psf-requests-2.28.0/tests/test_utils.py:814: Test only on Windows/home/hswong3i/Documents/osc/psf-requests-2.28.0/tests/test_utils.py:814: Test only on Windows/home/hswong3i/Documents/osc/psf-requests-2.28.0/tests/test_utils.py:814: Test only on Windows/home/hswong3i/Documents/osc/psf-requests-2.28.0/tests/test_utils.py:814: Test only on Windows/home/hswong3i/Documents/osc/psf-requests-2.28.0/tests/test_utils.py:814: Test only on Windows/home/hswong3i/Documents/osc/psf-requests-2.28.0/tests/test_utils.py:814: Test only on Windows/home/hswong3i/Documents/osc/psf-requests-2.28.0/tests/test_utils.py:814: Test only on Windows/home/hswong3i/Documents/osc/psf-requests-2.28.0/tests/test_utils.py:814: Test only on Windows/home/hswong3i/Documents/osc/psf-requests-2.28.0/tests/test_utils.py:867: Test only on Windows