From 57cdb573312c2fae28f7fcf0b06aa00df871739d Mon Sep 17 00:00:00 2001 From: InfinityPacer <160988576+InfinityPacer@users.noreply.github.com> Date: Sun, 30 Jun 2024 11:44:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20retry=E6=94=AF=E6=8C=81=E7=AB=8B?= =?UTF-8?q?=E5=8D=B3=E6=8A=9B=E5=87=BA=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/utils/common.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/utils/common.py b/app/utils/common.py index 5708fbfd..497ad15b 100644 --- a/app/utils/common.py +++ b/app/utils/common.py @@ -6,6 +6,8 @@ from typing import Any from Crypto import Random from Crypto.Cipher import AES +from app.schemas.exception import ImmediateException + def retry(ExceptionToCheck: Any, tries: int = 3, delay: int = 3, backoff: int = 2, logger: Any = None): @@ -23,6 +25,8 @@ def retry(ExceptionToCheck: Any, while mtries > 1: try: return f(*args, **kwargs) + except ImmediateException: + raise except ExceptionToCheck as e: msg = f"{str(e)}, {mdelay} 秒后重试 ..." if logger: