Timeout configuration. Timeouts can be defined as a default for a pool: .. code-block:: python import urllib3 timeout = urllib3.util.Timeout(connect=2.0, read=7.0) http = urllib3.PoolManager(timeout=timeout) resp = http.request("GET", "https://example.co
| 23 | |
| 24 | |
| 25 | class Timeout: |
| 26 | """Timeout configuration. |
| 27 | |
| 28 | Timeouts can be defined as a default for a pool: |
| 29 | |
| 30 | .. code-block:: python |
| 31 | |
| 32 | import urllib3 |
| 33 | |
| 34 | timeout = urllib3.util.Timeout(connect=2.0, read=7.0) |
| 35 | |
| 36 | http = urllib3.PoolManager(timeout=timeout) |
| 37 | |
| 38 | resp = http.request("GET", "https://example.com/") |
| 39 | |
| 40 | print(resp.status) |
| 41 | |
| 42 | Or per-request (which overrides the default for the pool): |
| 43 | |
| 44 | .. code-block:: python |
| 45 | |
| 46 | response = http.request("GET", "https://example.com/", timeout=Timeout(10)) |
| 47 | |
| 48 | Timeouts can be disabled by setting all the parameters to ``None``: |
| 49 | |
| 50 | .. code-block:: python |
| 51 | |
| 52 | no_timeout = Timeout(connect=None, read=None) |
| 53 | response = http.request("GET", "https://example.com/", timeout=no_timeout) |
| 54 | |
| 55 | |
| 56 | :param total: |
| 57 | This combines the connect and read timeouts into one; the read timeout |
| 58 | will be set to the time leftover from the connect attempt. In the |
| 59 | event that both a connect timeout and a total are specified, or a read |
| 60 | timeout and a total are specified, the shorter timeout will be applied. |
| 61 | |
| 62 | Defaults to None. |
| 63 | |
| 64 | :type total: int, float, or None |
| 65 | |
| 66 | :param connect: |
| 67 | The maximum amount of time (in seconds) to wait for a connection |
| 68 | attempt to a server to succeed. Omitting the parameter will default the |
| 69 | connect timeout to the system default, probably `the global default |
| 70 | timeout in socket.py |
| 71 | <http://hg.python.org/cpython/file/603b4d593758/Lib/socket.py#l535>`_. |
| 72 | None will set an infinite timeout for connection attempts. |
| 73 | |
| 74 | :type connect: int, float, or None |
| 75 | |
| 76 | :param read: |
| 77 | The maximum amount of time (in seconds) to wait between consecutive |
| 78 | read operations for a response from the server. Omitting the parameter |
| 79 | will default the read timeout to the system default, probably `the |
| 80 | global default timeout in socket.py |
| 81 | <http://hg.python.org/cpython/file/603b4d593758/Lib/socket.py#l535>`_. |
| 82 | None will set an infinite timeout. |
no outgoing calls