Intialize self.history if only the key is not in cache

This commit is contained in:
JasperSui 2021-07-22 14:47:32 +08:00
parent fe183fd3d2
commit d80b317b6a

View File

@ -121,7 +121,10 @@ class SimpleRateThrottle(BaseThrottle):
if self.key is None: if self.key is None:
return True return True
self.history = self.cache.get(self.key, deque()) self.history = self.cache.get(self.key)
if self.history is None:
self.history = deque()
self.now = self.timer() self.now = self.timer()
# Drop any requests from the history which have now passed the # Drop any requests from the history which have now passed the