From 132cd9e84353ab56c89111e1da8319d3ff062d7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Skar=C5=BCy=C5=84ski?= Date: Tue, 4 May 2021 12:24:00 +0200 Subject: [PATCH] add explicit timer method implementation --- rest_framework/throttling.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rest_framework/throttling.py b/rest_framework/throttling.py index 5195c9c5a..f43de34a2 100644 --- a/rest_framework/throttling.py +++ b/rest_framework/throttling.py @@ -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