Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,4 @@ of those changes to CLEARTYPE SRL.
| [@karolinepauls](https://karolinepauls.com) | Karoline Pauls |
| [@gurelkaynak](https://gurel.kaynak.link) | Gurel Kaynak |
| [@ksoviero-zengrc](https://github.com/ksoviero-zengrc) | Kevin Soviero |
| [@mikeroll](https://github.com/mikeroll) | Mikhail Bulash |
4 changes: 1 addition & 3 deletions dramatiq/rate_limits/backends/memcached.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ def incr_and_sum(self, key, keys, amount, maximum, ttl):
if value > maximum:
return False

# TODO: Drop non-callable keys in Dramatiq v2.
key_list = keys() if callable(keys) else keys
mapping = client.get_multi(key_list)
mapping = client.get_multi(keys())
total = amount + sum(mapping.values())
if total > maximum:
return False
Expand Down
6 changes: 2 additions & 4 deletions dramatiq/rate_limits/backends/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,14 @@ def incr_and_sum(self, key, keys, amount, maximum, ttl):
with self.client.pipeline() as pipe:
while True:
try:
# TODO: Drop non-callable keys in Dramatiq v2.
key_list = keys() if callable(keys) else keys
pipe.watch(key, *key_list)
pipe.watch(key, *keys())
value = int(pipe.get(key) or b"0")
value += amount
if value > maximum:
return False

# Fetch keys again to account for net/server latency.
values = pipe.mget(keys() if callable(keys) else keys)
values = pipe.mget(keys())
total = amount + sum(int(n) for n in values if n)
if total > maximum:
return False
Expand Down
4 changes: 1 addition & 3 deletions dramatiq/rate_limits/backends/stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ def incr_and_sum(self, key, keys, amount, maximum, ttl):
if value > maximum:
return False

# TODO: Drop non-callable keys in Dramatiq v2.
key_list = keys() if callable(keys) else keys
values = sum(self._get(k, default=0) for k in key_list)
values = sum(self._get(k, default=0) for k in keys())
total = amount + values
if total > maximum:
return False
Expand Down