跳到主要内容
版本:0.3.x

SafePoolManager

私有上下文源码

with syncstream.webtools.SafePoolManager(
num_pools: int = 10,
headers: dict[str, str] | None = None,
**connection_pool_kw
) as pool:
pool: SafePoolManager

支持上下文的urllib3.PoolManager的封装。

危险

这是私有类,用户不应使用它。

参数

参见

https://urllib3.readthedocs.io/en/stable/reference/urllib3.poolmanager.html

范例

使用上下文管理连接

use_pool_context.py
from syncstream.webtools import SafePoolManager


with SafePoolManager() as pool:
with pool.request("get", "https://google.com") as req:
# req已经由SafeRequest管理了。
print(req.status)