安装 pip install retry Retry装饰器 retry(exceptions=Exception, tries=-1, delay=0, max_delay=None, backoff=1, jitter=0, logger=logging_logger): """Return a retry decorator. :param exceptions: an exception or a tuple of exceptions to catch.
介绍 tenacity is an Apache 2.0 licensed general-purpose retrying library, written in Python, to simplify the task of adding retry behavior to just about anything. It originates from a fork of retrying which is sadly no longer maintained. Tenacity isn’t
在写业务时, 有个业务需要在return某种情况下,进行重试. 代码类似于下面 from retrying import retry def verify(self): try: return self.verify_1() except RetryError: .... def retry_if_result(result): """Return True if we should retry (in this case when result is 网络故障), Fals