summary refs log tree commit diff
path: root/synapse/api/ratelimiting.py
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2021-04-23 14:12:47 +0100
committerAndrew Morgan <andrew@amorgan.xyz>2021-04-23 14:12:47 +0100
commitd2b3c47ba31fec1df4d06f1c2aa7ed29e309498d (patch)
tree7a80e170fdec14dfd3e78cd4984ff39c89beb48a /synapse/api/ratelimiting.py
parentMerge commit 'd9f1dccba' into anoa/dinsic_release_1_31_0 (diff)
parentClean up the user directory sample config section (#9385) (diff)
downloadsynapse-d2b3c47ba31fec1df4d06f1c2aa7ed29e309498d.tar.xz
Merge commit 'e22b71810' into anoa/dinsic_release_1_31_0
Diffstat (limited to 'synapse/api/ratelimiting.py')
-rw-r--r--synapse/api/ratelimiting.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/synapse/api/ratelimiting.py b/synapse/api/ratelimiting.py

index 5d9d5a228f..c3f07bc1a3 100644 --- a/synapse/api/ratelimiting.py +++ b/synapse/api/ratelimiting.py
@@ -14,7 +14,7 @@ # limitations under the License. from collections import OrderedDict -from typing import Any, Optional, Tuple +from typing import Hashable, Optional, Tuple from synapse.api.errors import LimitExceededError from synapse.types import Requester @@ -42,7 +42,9 @@ class Ratelimiter: # * How many times an action has occurred since a point in time # * The point in time # * The rate_hz of this particular entry. This can vary per request - self.actions = OrderedDict() # type: OrderedDict[Any, Tuple[float, int, float]] + self.actions = ( + OrderedDict() + ) # type: OrderedDict[Hashable, Tuple[float, int, float]] def can_requester_do_action( self, @@ -82,7 +84,7 @@ class Ratelimiter: def can_do_action( self, - key: Any, + key: Hashable, rate_hz: Optional[float] = None, burst_count: Optional[int] = None, update: bool = True, @@ -175,7 +177,7 @@ class Ratelimiter: def ratelimit( self, - key: Any, + key: Hashable, rate_hz: Optional[float] = None, burst_count: Optional[int] = None, update: bool = True,