Skip to content
Myr

allow urllib3 Timeout objects as timeout parameter for HTTPAdapter.send()

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

omit timeout argument when calling urlopen on the connection. this allows setting a default timeout at connection pool level: adapter.poolmanager.connection_pool_kw['timeout'] = urllib3.Timeout(...)

authored by Alexander 'Leo' Bergolth · committed by Alexander 'Leo' Bergolth · parent 993cbf5 · Browse files · 1 file+10 added−4 removed
This commit

State

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

Diff stats

1 file+10 added−4 removed

  • other:+10 added−4 removed

1 file+10 added−4 removed

modified:requests/adapters.py+10 added-4 removed
389 unmodified lines
390 :param stream: (optional) Whether to stream the request content.391 :param timeout: (optional) How long to wait for the server to send392 data before giving up, as a float, or a :ref:`(connect timeout,393 read timeout) <timeouts>` tuple.394 :type timeout: float or tuple394 :type timeout: float or tuple or urllib3 Timeout object395 :param verify: (optional) Either a boolean, in which case it controls whether396 we verify the server's TLS certificate, or a string, in which case it397 must be a path to a CA bundle to use398 :param cert: (optional) Any user-provided SSL certificate to be trusted.
8 unmodified lines
407 self.add_headers(request)408409 chunked = not (request.body is None or 'Content-Length' in request.headers)410411 412 if isinstance(timeout, TimeoutSauce):413 pass411 if isinstance(timeout, tuple):414 elif isinstance(timeout, tuple):415 try:416 connect, read = timeout417 timeout = TimeoutSauce(connect=connect, read=read)418 except ValueError as e:
1 unmodified line
420 err = ("Invalid timeout {0}. Pass a (connect, read) "421 "timeout tuple, or a single float to set "422 "both timeouts to the same value".format(timeout))423 raise ValueError(err)421 else:424 elif timeout is not None:425 timeout = TimeoutSauce(connect=timeout, read=timeout)426427 try:428 if not chunked:429 kwargs = {}430 if timeout is not None:431 kwargs['timeout'] = timeout432 resp = conn.urlopen(433 method=request.method,434 url=url,435 body=request.body,
2 unmodified lines
438 assert_same_host=False,439 preload_content=False,440 decode_content=False,441 retries=self.max_retries,436 timeout=timeout442 **kwargs443 )444445 # Send the request.446 else:
76 unmodified lines