Skip to content

Commit 5fab10e

Browse files
committed
Store id'ed cooldowns within state
1 parent 7bbc23c commit 5fab10e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cooldowns/cooldown.py

+6
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ def cooldown(
6868
"""
6969
_cooldown: Cooldown = Cooldown(limit, time_period, bucket, cooldown_id=cooldown_id)
7070

71+
if cooldown_id:
72+
utils.shared_cooldown_refs[cooldown_id] = _cooldown
73+
7174
def decorator(func: Callable) -> Callable:
7275
if not asyncio.iscoroutinefunction(func):
7376
raise RuntimeError("Expected `func` to be a coroutine")
@@ -206,6 +209,9 @@ def __init__(
206209
self._clean_task: Optional[asyncio.Task] = None
207210
# self._clean_task = asyncio.create_task(self._keep_buckets_clear())
208211

212+
if cooldown_id:
213+
utils.shared_cooldown_refs[cooldown_id] = self
214+
209215
async def __aenter__(self) -> "Cooldown":
210216
if not self._clean_task:
211217
self._clean_task = asyncio.create_task(self._keep_buckets_clear())

0 commit comments

Comments
 (0)