From 818b4bf8b354d43360e3fd9d0b10440636a25212 Mon Sep 17 00:00:00 2001 From: Val Neekman Date: Thu, 27 Feb 2014 12:27:54 -0800 Subject: [PATCH] handle negative time value and prevent a divide by zero --- rest_framework/throttling.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rest_framework/throttling.py b/rest_framework/throttling.py index a946d837f..efa9fb949 100644 --- a/rest_framework/throttling.py +++ b/rest_framework/throttling.py @@ -136,6 +136,8 @@ class SimpleRateThrottle(BaseThrottle): remaining_duration = self.duration available_requests = self.num_requests - len(self.history) + 1 + if available_requests <= 0: + return None return remaining_duration / float(available_requests)