class PoolManager(RequestMethods): (source)
Known subclasses: urllib3.contrib.socks.SOCKSProxyManager
, urllib3.poolmanager.ProxyManager
Allows for arbitrary requests while transparently keeping track of necessary connection pools for you. :param num_pools: Number of connection pools to cache before discarding the least recently used pool. :param headers: Headers to include with all requests, unless other headers are given explicitly. :param \**connection_pool_kw: Additional parameters are used to create fresh :class:`urllib3.connectionpool.ConnectionPool` instances. Example:: >>> manager = PoolManager(num_pools=2) >>> r = manager.request('GET', 'http://google.com/') >>> r = manager.request('GET', 'http://google.com/mail') >>> r = manager.request('GET', 'http://yahoo.com/') >>> len(manager.pools) 2
Method | __enter__ |
Undocumented |
Method | __exit__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | clear |
Empty our store of pools and direct them all to close. |
Method | connection |
Get a :class:`urllib3.connectionpool.ConnectionPool` based on the request context. |
Method | connection |
Get a :class:`urllib3.connectionpool.ConnectionPool` based on the host, port, and scheme. |
Method | connection |
Get a :class:`urllib3.connectionpool.ConnectionPool` based on the provided pool key. |
Method | connection |
Similar to :func:`urllib3.connectionpool.connection_from_url`. |
Method | urlopen |
Same as :meth:`urllib3.HTTPConnectionPool.urlopen` with custom cross-host redirect logic and only sends the request-uri portion of the ``url``. |
Class Variable | proxy |
Undocumented |
Class Variable | proxy |
Undocumented |
Instance Variable | connection |
Undocumented |
Instance Variable | key |
Undocumented |
Instance Variable | pool |
Undocumented |
Instance Variable | pools |
Undocumented |
Method | _merge |
Merge a dictionary of override values for self.connection_pool_kw. |
Method | _new |
Create a new :class:`urllib3.connectionpool.ConnectionPool` based on host, port, scheme, and any additional pool keyword arguments. |
Method | _proxy |
Indicates if the proxy requires the complete destination URL in the request. Normally this is only needed when not using an HTTP CONNECT tunnel. |
Method | _validate |
Validates that were not attempting to do TLS in TLS connections on Python2 or with unsupported SSL implementations. |
Inherited from RequestMethods
:
Method | request |
Make a request using :meth:`urlopen` with the appropriate encoding of ``fields`` based on the ``method`` used. |
Method | request |
Make a request using :meth:`urlopen` with the ``fields`` encoded in the body. This is useful for request methods like POST, PUT, PATCH, etc. |
Method | request |
Make a request using :meth:`urlopen` with the ``fields`` encoded in the url. This is useful for request methods like GET, HEAD, DELETE, etc. |
Instance Variable | headers |
Undocumented |
Class Variable | _encode |
Undocumented |
Empty our store of pools and direct them all to close. This will not affect in-flight connections, but they will not be re-used after completion.
Get a :class:`urllib3.connectionpool.ConnectionPool` based on the request context. ``request_context`` must at least contain the ``scheme`` key and its value must be a key in ``key_fn_by_scheme`` instance variable.
urllib3.poolmanager.ProxyManager
Get a :class:`urllib3.connectionpool.ConnectionPool` based on the host, port, and scheme. If ``port`` isn't given, it will be derived from the ``scheme`` using ``urllib3.connectionpool.port_by_scheme``. If ``pool_kwargs`` is provided, it is merged with the instance's ``connection_pool_kw`` variable and used to create the new connection pool, if one is needed.
Get a :class:`urllib3.connectionpool.ConnectionPool` based on the provided pool key. ``pool_key`` should be a namedtuple that only contains immutable objects. At a minimum it must have the ``scheme``, ``host``, and ``port`` fields.
Similar to :func:`urllib3.connectionpool.connection_from_url`. If ``pool_kwargs`` is not provided and a new pool needs to be constructed, ``self.connection_pool_kw`` is used to initialize the :class:`urllib3.connectionpool.ConnectionPool`. If ``pool_kwargs`` is provided, it is used instead. Note that if a new pool does not need to be created for the request, the provided ``pool_kwargs`` are not used.
urllib3.request.RequestMethods.urlopen
urllib3.poolmanager.ProxyManager
Same as :meth:`urllib3.HTTPConnectionPool.urlopen` with custom cross-host redirect logic and only sends the request-uri portion of the ``url``. The given ``url`` parameter must be absolute, such that an appropriate :class:`urllib3.connectionpool.ConnectionPool` can be chosen for it.
Merge a dictionary of override values for self.connection_pool_kw. This does not modify self.connection_pool_kw and returns a new dict. Any keys in the override dictionary with a value of ``None`` are removed from the merged dictionary.
Create a new :class:`urllib3.connectionpool.ConnectionPool` based on host, port, scheme, and any additional pool keyword arguments. If ``request_context`` is provided, it is provided as keyword arguments to the pool class used. This method is used to actually create the connection pools handed out by :meth:`connection_from_url` and companion methods. It is intended to be overridden for customization.