From c9df3d807f7134f58f4a84dc8b80e9dc98c62f3a Mon Sep 17 00:00:00 2001 From: SVN-Git Migration Date: Thu, 8 Oct 2015 13:19:42 -0700 Subject: Imported Upstream version 1.10.4 --- docs/pools.rst | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'docs/pools.rst') 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) + ... + + >>> print(pool.pool) + None Helpers ------- -- cgit v1.2.3