aboutsummaryrefslogtreecommitdiff
path: root/docs/pools.rst
diff options
context:
space:
mode:
authorSVN-Git Migration <python-modules-team@lists.alioth.debian.org>2015-10-08 13:19:42 -0700
committerSVN-Git Migration <python-modules-team@lists.alioth.debian.org>2015-10-08 13:19:42 -0700
commitc9df3d807f7134f58f4a84dc8b80e9dc98c62f3a (patch)
tree2c14ecbc5e10513419b15f690e7bddfdb2dab75e /docs/pools.rst
parentb6ab7bae87b22c6fae783e8850533219d3bf8a29 (diff)
downloadpython-urllib3-c9df3d807f7134f58f4a84dc8b80e9dc98c62f3a.tar
python-urllib3-c9df3d807f7134f58f4a84dc8b80e9dc98c62f3a.tar.gz
Imported Upstream version 1.10.4
Diffstat (limited to 'docs/pools.rst')
-rw-r--r--docs/pools.rst17
1 files changed, 16 insertions, 1 deletions
diff --git a/docs/pools.rst b/docs/pools.rst
index 63cb7d1..9cc2be9 100644
--- a/docs/pools.rst
+++ b/docs/pools.rst
@@ -33,7 +33,22 @@ If you need to make requests to the same host repeatedly, then you should use a
By default, the pool will cache just one connection. If you're planning on using
such a pool in a multithreaded environment, you should set the ``maxsize`` of
the pool to a higher number, such as the number of threads. You can also control
-many other variables like timeout, blocking, and default headers.
+many other variables like timeout, blocking, and default headers.
+
+A ConnectionPool can be used as a context manager to automatically clear the
+pool after usage.
+
+.. doctest ::
+
+ >>> from urllib3 import HTTPConnectionPool
+ >>> with HTTPConnectionPool('ajax.googleapis.com', maxsize=1) as pool:
+ ... r = pool.request('GET', '/ajax/services/search/web',
+ ... fields={'q': 'urllib3', 'v': '1.0'})
+ ... print(pool.pool)
+ ...
+ <queue.LifoQueue object at 0x7f67367dfcf8>
+ >>> print(pool.pool)
+ None
Helpers
-------