add explicit timer method implementation

This commit is contained in:
Łukasz Skarżyński 2021-05-04 12:24:00 +02:00
parent 7cd5ae7275
commit 132cd9e843

View File

@ -60,7 +60,6 @@ class SimpleRateThrottle(BaseThrottle):
Previous request information used for throttling is stored in the cache.
"""
cache = default_cache
timer = staticmethod(time.time)
cache_format = 'throttle_%(scope)s_%(ident)s'
scope = None
THROTTLE_RATES = api_settings.DEFAULT_THROTTLE_RATES
@ -131,6 +130,10 @@ class SimpleRateThrottle(BaseThrottle):
return self.throttle_failure()
return self.throttle_success()
def timer(self):
"""Time in seconds since the epoch."""
return time.time()
def throttle_success(self):
"""
Inserts the current request's timestamp along with the key