Skip to content

Commit 7413e61

Browse files
committed
exclusive expects coroutines
1 parent 911802b commit 7413e61

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/service-library/src/servicelib/redis/_decorators.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import contextlib
33
import functools
44
import 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

88
import 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

Comments
 (0)