當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。