diff options
author | Erik Johnston <erikj@element.io> | 2024-05-18 12:03:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-18 12:03:30 +0100 |
commit | 52af16c56175160512420d8654ac558a1e5af541 (patch) | |
tree | 7c9a9e4dbae6265ebff3cb08809a6fbac7fcbfc6 /synapse/api/ratelimiting.py | |
parent | Federated Knocking Endpoints added (missing in Docu) (#17058) (diff) | |
download | synapse-52af16c56175160512420d8654ac558a1e5af541.tar.xz |
Add a short sleep if the request is rate-limited (#17210)
This helps prevent clients from "tight-looping" retrying their request.
Diffstat (limited to 'synapse/api/ratelimiting.py')
-rw-r--r-- | synapse/api/ratelimiting.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/synapse/api/ratelimiting.py b/synapse/api/ratelimiting.py index a73626bc86..a99a9e09fc 100644 --- a/synapse/api/ratelimiting.py +++ b/synapse/api/ratelimiting.py @@ -316,6 +316,10 @@ class Ratelimiter: ) if not allowed: + # We pause for a bit here to stop clients from "tight-looping" on + # retrying their request. + await self.clock.sleep(0.5) + raise LimitExceededError( limiter_name=self._limiter_name, retry_after_ms=int(1000 * (time_allowed - time_now_s)), |