MCPcopy
hub / github.com/urllib3/urllib3 / _new_pool

Method _new_pool

src/urllib3/poolmanager.py:243–279  ·  view source on GitHub ↗

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

(
        self,
        scheme: str,
        host: str,
        port: int,
        request_context: dict[str, typing.Any] | None = None,
    )

Source from the content-addressed store, hash-verified

241 return False
242
243 def _new_pool(
244 self,
245 scheme: str,
246 host: str,
247 port: int,
248 request_context: dict[str, typing.Any] | None = None,
249 ) -> HTTPConnectionPool:
250 """
251 Create a new :class:`urllib3.connectionpool.ConnectionPool` based on host, port, scheme, and
252 any additional pool keyword arguments.
253
254 If ``request_context`` is provided, it is provided as keyword arguments
255 to the pool class used. This method is used to actually create the
256 connection pools handed out by :meth:`connection_from_url` and
257 companion methods. It is intended to be overridden for customization.
258 """
259 pool_cls: type[HTTPConnectionPool] = self.pool_classes_by_scheme[scheme]
260 if request_context is None:
261 request_context = self.connection_pool_kw.copy()
262
263 # Default blocksize to _DEFAULT_BLOCKSIZE if missing or explicitly
264 # set to 'None' in the request_context.
265 if request_context.get("blocksize") is None:
266 request_context["blocksize"] = _DEFAULT_BLOCKSIZE
267
268 # Although the context has everything necessary to create the pool,
269 # this function has historically only used the scheme, host, and port
270 # in the positional args. When an API change is acceptable these can
271 # be removed.
272 for key in ("scheme", "host", "port"):
273 request_context.pop(key, None)
274
275 if scheme == "http":
276 for kw in SSL_KEYWORDS:
277 request_context.pop(kw, None)
278
279 return pool_cls(host, port, **request_context)
280
281 def clear(self) -> None:
282 """

Callers 2

test_proxy_verifiedMethod · 0.80

Calls 3

copyMethod · 0.80
getMethod · 0.80
popMethod · 0.80

Tested by 1

test_proxy_verifiedMethod · 0.64