python 指数退避。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 指数退避。相关的知识,希望对你有一定的参考价值。

from time import sleep


def try():
  success = False
  retries = 0
  max_retries = N
  while not success:
    # Execute task, success = True if successful
    if retries == max_retries:
      raise Error
    retries += 1
    sleep(2.**retries * 0.1)

以上是关于python 指数退避。的主要内容,如果未能解决你的问题,请参考以下文章