diff options
author | Andrey Petrov <andrey.petrov@shazow.net> | 2014-03-14 17:05:50 -0700 |
---|---|---|
committer | Andrey Petrov <andrey.petrov@shazow.net> | 2014-03-14 17:05:50 -0700 |
commit | 5b0bf2a06fc0909b1d019ba9eada784913edde9b (patch) | |
tree | 7ce8b554f33f902ff8e19a76886e161aac2e3adb /docs | |
parent | 772a3e9a5434e30dee4da587bb72de0913041233 (diff) | |
parent | ed885b2d87585e2e7efa637f434463dd3759c357 (diff) | |
download | urllib3-5b0bf2a06fc0909b1d019ba9eada784913edde9b.tar.gz |
Merge.
Diffstat (limited to 'docs')
-rw-r--r-- | docs/index.rst | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/docs/index.rst b/docs/index.rst index 61edafa6..ce543e0e 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -152,6 +152,33 @@ should use a :class:`~urllib3.poolmanager.PoolManager`. A :class:`~urllib3.connectionpool.ConnectionPool` is composed of a collection of :class:`httplib.HTTPConnection` objects. +Timeout +------- + +A timeout can be set to abort socket operations on individual connections after +a specified duration. This can be done with a float or integer, which sets the +timeout for the entire HTTP request, or an instance of :class:`~urllib3.util.Timeout` +which will give you more granular control over how much time is given to different +stages of the request. + +:: + + >>> # Timeout on pool with 7.0 for both connect and read. + >>> pool = HTTPConnectionPool('ajax.googleapis.com', timeout=7.0) + >>> pool.request(...) + + >>> # Timeout object on pool with infinite timeout for connections and 5 for read. + >>> pool = HTTPConnectionPool('ajax.googleapis.com', timeout=urllib3.util.Timeout(read=5)) + >>> pool.request(...) + + >>> # Timeout object on request with 3 for connect and 5 for read. + >>> pool = HTTPConnectionPool('ajax.googleapis.com', maxsize=1) + >>> r = pool.request('GET', '/ajax/services/search/web', timeout=urllib3.util.Timeout(connect=3, read=5)) + + >>> # Timeout object on request with 7.5 for read and connect combined. + >>> pool = HTTPConnectionPool('ajax.googleapis.com', maxsize=1) + >>> r = pool.request('GET', '/ajax/services/search/web', timeout=urllib3.util.Timeout(total=7.5)) + Foundation ---------- |