当前位置: 首页>>代码示例>>Python>>正文


Python HTTPAdapter.max_retries方法代码示例

本文整理汇总了Python中requests.adapters.HTTPAdapter.max_retries方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPAdapter.max_retries方法的具体用法?Python HTTPAdapter.max_retries怎么用?Python HTTPAdapter.max_retries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在requests.adapters.HTTPAdapter的用法示例。


在下文中一共展示了HTTPAdapter.max_retries方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from requests.adapters import HTTPAdapter [as 别名]
# 或者: from requests.adapters.HTTPAdapter import max_retries [as 别名]
    def __init__(self, config):
        self.config = config

        self.pool_manager = requests.Session()

        self.retry_methods = frozenset(['GET', 'HEAD', 'DELETE', 'OPTIONS'])

        # noinspection PyTypeChecker
        adapter = HTTPAdapter(
                pool_connections=config.http_pool_connections,
                pool_maxsize=config.http_pool_size,
                # max_retries=Retry(
                #         method_whitelist=self.retry_methods,
                #         total=config.http_max_retries,
                #         connect=config.http_max_retries,
                #         read=config.http_max_retries,
                #         status_forcelist=range(500, 600)
                # ),
                # pool_block=True
        )
        adapter.max_retries = config.http_max_retries
        self.pool_manager.mount('https://', adapter)
        self.pool_manager.mount('http://', adapter)

        self.pool_manager.verify = bool(self.config.verify_ssl)
开发者ID:attune-api,项目名称:attune-python,代码行数:27,代码来源:rest.py

示例2: send

# 需要导入模块: from requests.adapters import HTTPAdapter [as 别名]
# 或者: from requests.adapters.HTTPAdapter import max_retries [as 别名]
 def send(self):
     self.url = "%s%s" % (self.base_url, self.path)
     prepped = self.prepare()
     s = Session()
     # print(self.data)
     h = HTTPAdapter()
     h.max_retries = 10
     s.mount('http://', h)
     s.mount('https://', h)
     response = s.send(prepped)
     response.needs_user_token = self.needs_user_token
     response.original_request = self
     return response
开发者ID:headphonesjones,项目名称:Blohaute,代码行数:15,代码来源:request.py

示例3: __init__

# 需要导入模块: from requests.adapters import HTTPAdapter [as 别名]
# 或者: from requests.adapters.HTTPAdapter import max_retries [as 别名]
    def __init__(self, app_id):

        self.app_id = app_id

        # Provides cookie persistence, connection-pooling, and configuration.
        self.session = requests.Session()

        # Create an requests HTTP adapter and set number of retries to attempt
        adapter = HTTPAdapter()
        adapter.max_retries = 5

        # Register transport adapter for given URL prefix and enable connection retrying.
        self.session.mount(self.API_URL_PREFIX, adapter=adapter)
开发者ID:danielterhorst,项目名称:open_exchange_rates,代码行数:15,代码来源:client.py


注:本文中的requests.adapters.HTTPAdapter.max_retries方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。