<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      python retry feature

      簡單的retry 功能有兩種實現方法
      • retry module - 可以實現簡單的retry, 指定retry 次數。
      • backoff module - 相對于retry 模塊, 功能更豐富一點。 
      retry example
      1 @retry(InvalidLogin, tries=2, delay=0)
      2 @retry(httpx.ConnectError, tries=5, delay=2) # decorator 可以嵌套使用
      3 def get(cls, endpoint: str):
      4     。。。。
      View Code

      backoff example

      1 @backoff.on_exception(
      2     backoff.constant,
      3     Exception,
      4     max_tries=3,
      5     giveup=fatal_code,
      6     on_backoff=backoff_fun,
      7 )
      8 def test2():
      9    ...
      View Code

      通過查看backoff onexception 的signature, 學習下用法啊

      """Returns decorator for backoff and retry triggered by exception.
      
      
      Args:
          wait_gen: A generator yielding successive wait times in
              seconds. ## 一個generator, 可以before retry需要等待的時間。
          exception: An exception type (or tuple of types) which triggers
              backoff. # 顯而易見, exception or tuple of exception
          max_tries: The maximum number of attempts to make before giving
              up. Once exhausted, the exception will be allowed to escape.
              The default value of None means there is no limit to the
              number of tries. If a callable is passed, it will be
              evaluated at runtime and its return value used.
          max_time: The maximum total amount of time to try for before
              giving up. Once expired, the exception will be allowed to
              escape. If a callable is passed, it will be
              evaluated at runtime and its return value used.
          jitter: A function of the value yielded by wait_gen returning
              the actual time to wait. This distributes wait times
              stochastically in order to avoid timing collisions across
              concurrent clients. Wait times are jittered by default
              using the full_jitter function. Jittering may be disabled
              altogether by passing jitter=None.
          giveup: Function accepting an exception instance and
              returning whether or not to give up. Optional. The default
              is to always continue.  # giveup=fatal_code
      ```
      def fatal_code(e): # 入參是exception instance
          # return type(e) == 'TypeError'
          e_type = type(e)
          logger.info(f"Give up code. error is - {e_type} - {str(e)} ..")
          return 0 # 返回0 or 1, 0: retry 繼續, 不giveup
      ```
          on_success: Callable (or iterable of callables) with a unary
              signature to be called in the event of success. The
              parameter is a dict containing details about the invocation.
          on_backoff: Callable (or iterable of callables) with a unary
              signature to be called in the event of a backoff. The
              parameter is a dict containing details about the invocation.
      ```
      這三個on function, 都是類似的用法, backoff的時候做什么, 用法on_backoff=backoff_fun
      def backoff_fun(detail): # detail is a dict, 包括你需要的所有的東西
          logger.info(f"backoff function {detail}")
          return 1
      ```
          on_giveup: Callable (or iterable of callables) with a unary
              signature to be called in the event that max_tries
              is exceeded.  The parameter is a dict containing details
              about the invocation.
          raise_on_giveup: Boolean indicating whether the registered exceptions
              should be raised on giveup. Defaults to `True`
          logger: Name or Logger object to log to. Defaults to 'backoff'.
          backoff_log_level: log level for the backoff event. Defaults to "INFO"
          giveup_log_level: log level for the give up event. Defaults to "ERROR"
          **wait_gen_kwargs: Any additional keyword args specified will be
              passed to wait_gen when it is initialized.  Any callable
              args will first be evaluated and their return values passed.
              This is useful for runtime configuration.

       

      posted on 2023-02-13 15:09  MissLi12138  閱讀(51)  評論(0)    收藏  舉報

      導航

      主站蜘蛛池模板: 江永县| 日韩精品久久久肉伦网站| 精品综合一区二区三区四区| 久久精品国产久精国产69| 国模一区二区三区私拍视频| 朝鲜女子内射杂交bbw| 亚洲第一精品一二三区| 久久亚洲精品人成综合网| 亚洲高清WWW色好看美女| 视频二区中文字幕在线| 国产福利永久在线视频无毒不卡| 日韩精品亚洲精品第一页| 国产乱久久亚洲国产精品| 亚洲va久久久噜噜噜久久狠狠| 国内精品卡一卡二卡三| 久久天天躁狠狠躁夜夜躁2o2o| 久久婷婷五月综合色国产免费观看| 沂南县| 国产日产亚洲系列av| 欧美交A欧美精品喷水| 亚洲精品宾馆在线精品酒店| 国产视频一区二区在线看| 91亚洲国产三上悠亚在线播放 | 亚洲色偷偷色噜噜狠狠99| 99久久久国产精品免费无卡顿| AI做受???高潮AAAA视频| 国产一区二区日韩在线| 波多野结衣av高清一区二区三区| 亚洲精品久久国产高清小说| 九九在线精品国产| 精品国产免费一区二区三区香蕉 | 成人久久精品国产亚洲av| 免费无码肉片在线观看| 临潭县| 伊人久久大香线蕉综合观| 亚洲AV福利天堂在线观看| 国内精品免费久久久久电影院97| 亚洲国产欧美在线人成| 4hu四虎永久在线观看| 波多野无码中文字幕av专区| 亚洲精品国产av一区二区|