aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2020-01-21 19:50:37 -0500
committerRapptz <[email protected]>2020-01-21 19:50:37 -0500
commite21d49c98014b0f25d2e3f8a28996b80ef32c525 (patch)
treeb3a4c02c02538a7f054c4cdc03f70395d069717c
parentDrop final 0 in versionadded numbers in api.rst (diff)
downloaddiscord.py-e21d49c98014b0f25d2e3f8a28996b80ef32c525.tar.xz
discord.py-e21d49c98014b0f25d2e3f8a28996b80ef32c525.zip
[commands] Only clean semaphore when there are no waiters
-rw-r--r--discord/ext/commands/cooldowns.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/discord/ext/commands/cooldowns.py b/discord/ext/commands/cooldowns.py
index 9efb5104..5aa89cb1 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]