zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    type和object详解
    元类+单例
    单表查询和多表查询
    外键
    存储引擎,MySQL中的数据类型及约束
    壹拾壹




  • 原文地址:https://www.cnblogs.com/shadowwalker/p/5283372.html
Copyright © 2011-2022 走看看