Skip to content

Commit 158df3a

Browse files
committed
fix(http): check bucket before sending a request for a cooldown.
1 parent 7be091e commit 158df3a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

interactions/api/http.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,12 @@ async def request(self, route: Route, **kwargs) -> Optional[Any]:
157157
ratelimit: Event = self.ratelimits.get(bucket)
158158

159159
if ratelimit is None:
160-
self.ratelimits[bucket] = Event()
160+
self.ratelimits[bucket] = {"lock": Event(), "remaining": 0}
161+
else:
162+
if ratelimit.is_set():
163+
log.warning("The requested HTTP endpoint is still locked, waiting for it to clear.")
164+
ratelimit["lock"].wait(ratelimit["reset_after"])
165+
ratelimit["lock"].clear()
161166

162167
kwargs["headers"] = {**self._headers, **kwargs.get("headers", {})}
163168
kwargs["headers"]["Content-Type"] = "application/json"

0 commit comments

Comments
 (0)