Skip to content
Myr

Merge pull request #2187 from kevinburke/more-docs

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

Document Timeout behaviour

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 958845a, 34ea836 · Browse files · 7 files+28 added−34 removed
This commit

State

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

Diff stats

7 files+28 added−34 removed

  • other:+28 added−34 removed

7 files+28 added−34 removed

modified:docs/community/support.rst+1 added-1 removed
13 unmodified lines
1415File an Issue16-------------1718If you notice some unexpected behavior in Requests, or want to see support18If you notice some unexpected behaviour in Requests, or want to see support19for a new feature,20`file an issue on GitHub <https://github.com/kennethreitz/requests/issues>`_.2122
15 unmodified lines
modified:docs/user/advanced.rst+1 added-1 removed
192 unmodified lines
193Body Content Workflow194---------------------195196By default, when you make a request, the body of the response is downloaded197immediately. You can override this behavior and defer downloading the response197immediately. You can override this behaviour and defer downloading the response198body until you access the :class:`Response.content <requests.Response.content>`199attribute with the ``stream`` parameter::200201 tarball_url = 'https://github.com/kennethreitz/requests/tarball/master'
542 unmodified lines
modified:docs/api.rst+4 added-20 removed
58 unmodified lines
59.. 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.Timeout666768Status Code Lookup
179 unmodified lines
248 # this raises requests.exceptions.MissingSchema249 requests.get("http://example.org", proxies=proxies)250251250Behavioral Changes251~~~~~~~~~~~~~~~~~~252Behavioural Changes253~~~~~~~~~~~~~~~~~~~~~~~254255* Keys in the ``headers`` dictionary are now native strings on all Python256 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.259258* 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.263264 ::265266 tarball_url = 'https://github.com/kennethreitz/requests/tarball/master'267268 # One second timeout for the connection attempt269 # Unlimited time to download the tarball270 r = requests.get(tarball_url, stream=True, timeout=1)271272 # 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 lines
315 """Sends PreparedRequest object. Returns Response object.316317 :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 lines
modified:requests/api.py+6 added-2 removed
22 unmodified lines
23 :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 lines
modified:requests/exceptions.py+5 added-4 removed
44 unmodified lines
4546class Timeout(RequestException):47 """The request timed out.4849 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 """535455class 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.5757 Requests that produce this error are safe to retry58 Requests that produced this error are safe to retry.59 """606162class ReadTimeout(Timeout):
29 unmodified lines
modified:requests/sessions.py+7 added-4 removed
398 unmodified lines
399 :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