From bf39f103f56f932677158d0c52ccc863d9c26971 Mon Sep 17 00:00:00 2001 From: Krishnasis Mandal Date: Sat, 16 Mar 2024 14:17:47 +0100 Subject: [PATCH] fix: fix wrapper --- retry_later/lib.py | 14 +++++++------- retry_later/types.py | 5 +++++ 2 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 retry_later/types.py diff --git a/retry_later/lib.py b/retry_later/lib.py index 2bdce44..fbcb712 100644 --- a/retry_later/lib.py +++ b/retry_later/lib.py @@ -3,11 +3,9 @@ import logging import random from threading import Thread -from typing import Any, Callable, TypeVar, Union +from typing import Any, Callable, Union -RT = TypeVar("RT") -ARGS_T = tuple[list[str], ...] -KWARGS_T = dict[str, list[str]] +from .types import ARGS_T, KWARGS_T, RT def retry_later( @@ -27,20 +25,22 @@ def retry_later( max_delay (int): Maximum delay. (Default: -1, no limit) max_jitter (int): Maximum random jitter. (Default: 0, no jitter) exception (Exception): Exception or tuple of exceptions to retry. (Default: Exception Base class). + Returns: + None: No value is returned to the caller. """ def decorator(func: Callable[..., RT]) -> Callable[..., Any]: async def wrapper( *args: ARGS_T, **kwargs: KWARGS_T, - ) -> Any: + ) -> None: retries = 0 while retries < max_retries: try: if inspect.iscoroutinefunction(func): - return await func(*args, **kwargs) + await func(*args, **kwargs) else: - return func(*args, **kwargs) + func(*args, **kwargs) except exceptions as e: retries += 1 if retries >= max_retries: diff --git a/retry_later/types.py b/retry_later/types.py new file mode 100644 index 0000000..977d23a --- /dev/null +++ b/retry_later/types.py @@ -0,0 +1,5 @@ +from typing import TypeVar + +RT = TypeVar("RT") +ARGS_T = tuple[list[str], ...] +KWARGS_T = dict[str, list[str]]