From e21d49c98014b0f25d2e3f8a28996b80ef32c525 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Tue, 21 Jan 2020 19:50:37 -0500 Subject: [PATCH] [commands] Only clean semaphore when there are no waiters --- discord/ext/commands/cooldowns.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/discord/ext/commands/cooldowns.py b/discord/ext/commands/cooldowns.py index 9efb51041..5aa89cb1b 100644 --- a/discord/ext/commands/cooldowns.py +++ b/discord/ext/commands/cooldowns.py @@ -197,6 +197,9 @@ class _Semaphore: def locked(self): return self.value == 0 + def is_active(self): + return len(self._waiters) > 0 + def wake_up(self): while self._waiters: future = self._waiters.popleft() @@ -276,5 +279,5 @@ class MaxConcurrency: else: sem.release() - if sem.value >= self.number: + if sem.value >= self.number and not sem.is_active(): del self._mapping[key]