Document Timeout behaviour
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Kevin Burke · committed by Kevin Burke · parent 5f48336 · Browse files · 5 files·+24 added−30 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+24 added−30 removed
- other:+24 added−30 removed
Provenance
- Commit
dfa41af- Tree
4f09b8e- Author
Kevin Burke <kev@inburke.com>- Committer
Kevin Burke <kev@inburke.com>- Parent
5f48336
5 files changed+24 added−30 removed
modified:docs/api.rst+2 added-18 removed
58 unmodified lines59 .. autoexception:: requests.exceptions.ConnectionError60 .. autoexception:: requests.exceptions.HTTPError61 .. autoexception:: requests.exceptions.URLRequired62 .. autoexception:: requests.exceptions.TooManyRedirects63+.. autoexception:: requests.exceptions.ConnectTimeout64+.. autoexception:: requests.exceptions.ReadTimeout65 .. autoexception:: requests.exceptions.Timeout66 67 68 Status Code Lookup187 unmodified lines256 versions, i.e. bytestrings on Python 2 and unicode on Python 3. If the257 keys are not native strings (unicode on Python2 or bytestrings on Python 3)258 they will be converted to the native string type assuming UTF-8 encoding.259 258-* Timeouts behave slightly differently. On streaming requests, the timeout259- only applies to the connection attempt. On regular requests, the timeout260- is applied to the connection process and on to all attempts to read data from261- the underlying socket. It does *not* apply to the total download time for the262- request.263-264- ::265-266- tarball_url = 'https://github.com/kennethreitz/requests/tarball/master'267-268- # One second timeout for the connection attempt269- # Unlimited time to download the tarball270- r = requests.get(tarball_url, stream=True, timeout=1)271-272- # One second timeout for the connection attempt273- # Another full second timeout to download the tarball274- r = requests.get(tarball_url, timeout=1)275-modified:requests/adapters.py+4 added-2 removed
314 unmodified lines315 """Sends PreparedRequest object. Returns Response object.316 317 :param request: The :class:`PreparedRequest <PreparedRequest>` being sent.318 :param stream: (optional) Whether to stream the request content.319- :param timeout: (optional) The timeout on the request.320- :type timeout: float or tuple (connect timeout, read timeout), eg (3.1, 20)319+ :param timeout: (optional) How long to wait for the server to send320+ data before giving up, as a float, or a (`connect timeout, read321+ timeout <user/advanced.html#timeouts>`_) tuple.322+ :type timeout: float or tuple323 :param verify: (optional) Whether to verify SSL certificates.324 :param cert: (optional) Any user-provided SSL certificate to be trusted.325 :param proxies: (optional) The proxies dictionary to apply to the request.326 """99 unmodified linesmodified:requests/api.py+6 added-2 removed
22 unmodified lines23 :param params: (optional) Dictionary or bytes to be sent in the query string for the :class:`Request`.24 :param data: (optional) Dictionary, bytes, or file-like object to send in the body of the :class:`Request`.25 :param headers: (optional) Dictionary of HTTP Headers to send with the :class:`Request`.26 :param cookies: (optional) Dict or CookieJar object to send with the :class:`Request`.27- :param files: (optional) Dictionary of 'name': file-like-objects (or {'name': ('filename', fileobj)}) for multipart encoding upload.27+ :param files: (optional) Dictionary of ``'name': file-like-objects`` (or ``{'name': ('filename', fileobj)}``) for multipart encoding upload.28 :param auth: (optional) Auth tuple to enable Basic/Digest/Custom HTTP Auth.29- :param timeout: (optional) Float describing the timeout of the request in seconds.29+ :param timeout: (optional) How long to wait for the server to send data30+ before giving up, as a float, or a (`connect timeout, read timeout31+ <user/advanced.html#timeouts>`_) tuple.32+ :type timeout: float or tuple33 :param allow_redirects: (optional) Boolean. Set to True if POST/PUT/DELETE redirect following is allowed.34+ :type allow_redirects: bool35 :param proxies: (optional) Dictionary mapping protocol to the URL of the proxy.36 :param verify: (optional) if ``True``, the SSL cert will be verified. A CA_BUNDLE path can also be provided.37 :param stream: (optional) if ``False``, the response content will be immediately downloaded.38 :param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair.86 unmodified linesmodified:requests/exceptions.py+5 added-4 removed
44 unmodified lines45 46 class Timeout(RequestException):47 """The request timed out.48 49- Catching this error will catch both :exc:`ConnectTimeout` and50- :exc:`ReadTimeout` errors.49+ Catching this error will catch both50+ :exc:`~requests.exceptions.ConnectTimeout` and51+ :exc:`~requests.exceptions.ReadTimeout` errors.52 """53 54 55 class ConnectTimeout(ConnectionError, Timeout):55- """The request timed out while trying to connect to the server.56+ """The request timed out while trying to connect to the remote server.57 57- Requests that produce this error are safe to retry58+ Requests that produced this error are safe to retry.59 """60 61 62 class ReadTimeout(Timeout):29 unmodified linesmodified:requests/sessions.py+7 added-4 removed
398 unmodified lines399 :param headers: (optional) Dictionary of HTTP Headers to send with the400 :class:`Request`.401 :param cookies: (optional) Dict or CookieJar object to send with the402 :class:`Request`.403- :param files: (optional) Dictionary of 'filename': file-like-objects403+ :param files: (optional) Dictionary of ``'filename': file-like-objects``404 for multipart encoding upload.405 :param auth: (optional) Auth tuple or callable to enable406 Basic/Digest/Custom HTTP Auth.407- :param timeout: (optional) Float describing the timeout of the408- request in seconds.409- :param allow_redirects: (optional) Boolean. Set to True by default.407+ :param timeout: (optional) How long to wait for the server to send408+ data before giving up, as a float, or a (`connect timeout, read409+ timeout <user/advanced.html#timeouts>`_) tuple.410+ :type timeout: float or tuple411+ :param allow_redirects: (optional) Set to True by default.412+ :type allow_redirects: bool413 :param proxies: (optional) Dictionary mapping protocol to the URL of414 the proxy.415 :param stream: (optional) whether to immediately download the response416 content. Defaults to ``False``.243 unmodified lines