urllib3 PoolManager

A pool manager is an abstraction for a collection of ConnectionPools.
If you need to make requests to multiple hosts, then you can use a PoolManager, which takes care of maintaining
your pools so you don’t have to.

from urllib3 import PoolManager

manager = PoolManager(10)
res = manager.request('GET', 'baidu.com')
print(res.status)
print(res.data)

The PoolManager uses a Least Recently Used (LRU) policy for discarding old pools. That is, if you set the PoolManager
num_pools to 10, then after making requests to 11 or more different hosts, the least recently used pools will be
cleaned up eventually.
Cleanup of stale pools does not happen immediately but can be forced when used as a context manager.

with PoolManager(10) as manager:
res = manager.request('GET', 'baidu.com')
res = manager.request('GET', 'bing.com')

API

urllib3 PoolManager

上一篇:Swift 3.0 【Swift 3.0 相较于 Swift 2.2 的变化】


下一篇:如何成为一位优秀的创业CEO