OpenQuizz
Une application de gestion des contenus pédagogiques
PoolManager Class Reference
Inheritance diagram for PoolManager:
Collaboration diagram for PoolManager:

Public Member Functions

def __init__ (self, num_pools=10, headers=None, **connection_pool_kw)
 
def __enter__ (self)
 
def __exit__ (self, exc_type, exc_val, exc_tb)
 
def clear (self)
 
def connection_from_host (self, host, port=None, scheme="http", pool_kwargs=None)
 
def connection_from_context (self, request_context)
 
def connection_from_pool_key (self, pool_key, request_context=None)
 
def connection_from_url (self, url, pool_kwargs=None)
 
def urlopen (self, method, url, redirect=True, **kw)
 
- Public Member Functions inherited from RequestMethods
def __init__ (self, headers=None)
 
def urlopen (self, method, url, body=None, headers=None, encode_multipart=True, multipart_boundary=None, **kw)
 
def request (self, method, url, fields=None, headers=None, **urlopen_kw)
 
def request_encode_url (self, method, url, fields=None, headers=None, **urlopen_kw)
 
def request_encode_body (self, method, url, fields=None, headers=None, encode_multipart=True, multipart_boundary=None, **urlopen_kw)
 

Data Fields

 connection_pool_kw
 
 pools
 
 pool_classes_by_scheme
 
 key_fn_by_scheme
 
- Data Fields inherited from RequestMethods
 headers
 

Static Public Attributes

 proxy
 
 proxy_config
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  num_pools = 10,
  headers = None,
**  connection_pool_kw 
)

Member Function Documentation

◆ __enter__()

def __enter__ (   self)

◆ __exit__()

def __exit__ (   self,
  exc_type,
  exc_val,
  exc_tb 
)

◆ clear()

def clear (   self)
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.

◆ connection_from_context()

def connection_from_context (   self,
  request_context 
)
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.

◆ connection_from_host()

def connection_from_host (   self,
  host,
  port = None,
  scheme = "http",
  pool_kwargs = None 
)
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.

Reimplemented in ProxyManager.

◆ connection_from_pool_key()

def connection_from_pool_key (   self,
  pool_key,
  request_context = None 
)
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.

◆ connection_from_url()

def connection_from_url (   self,
  url,
  pool_kwargs = None 
)
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.

◆ urlopen()

def urlopen (   self,
  method,
  url,
  redirect = True,
**  kw 
)
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.

Reimplemented in ProxyManager.

Field Documentation

◆ connection_pool_kw

connection_pool_kw

◆ key_fn_by_scheme

key_fn_by_scheme

◆ pool_classes_by_scheme

pool_classes_by_scheme

◆ pools

pools

◆ proxy

proxy
static

◆ proxy_config

proxy_config
static

The documentation for this class was generated from the following file: