22import contextlib
33import functools
44import logging
5- from collections .abc import Callable
6- from typing import Awaitable , ParamSpec , TypeVar
5+ from collections .abc import Callable , Coroutine
6+ from typing import Any , ParamSpec , TypeVar
77
88import redis .exceptions
99
@@ -25,7 +25,9 @@ def exclusive(
2525 * ,
2626 lock_key : str | Callable [..., str ],
2727 lock_value : bytes | str | None = None ,
28- ) -> Callable [[Callable [P , Awaitable [R ]]], Callable [P , Awaitable [R ]]]:
28+ ) -> Callable [
29+ [Callable [P , Coroutine [Any , Any , R ]]], Callable [P , Coroutine [Any , Any , R ]]
30+ ]:
2931 """
3032 Define a method to run exclusively across
3133 processes by leveraging a Redis Lock.
@@ -45,8 +47,8 @@ def exclusive(
4547 raise ValueError (msg )
4648
4749 def decorator (
48- func : Callable [P , Awaitable [ R ]],
49- ) -> Callable [P , Awaitable [ R ]]:
50+ func : Callable [P , Coroutine [ Any , Any , R ]],
51+ ) -> Callable [P , Coroutine [ Any , Any , R ]]:
5052 @functools .wraps (func )
5153 async def wrapper (* args : P .args , ** kwargs : P .kwargs ) -> R :
5254 redis_lock_key = (
0 commit comments