diff options
| author | Val Neekman | 2014-02-27 12:27:54 -0800 |
|---|---|---|
| committer | Val Neekman | 2014-02-27 12:27:54 -0800 |
| commit | 818b4bf8b354d43360e3fd9d0b10440636a25212 (patch) | |
| tree | 5de421d6b2bfcfaa3744a72f1b492cf7e4881472 | |
| parent | 6e92e415aa7dd6871ef7d6500a85cacebde8dca2 (diff) | |
| download | django-rest-framework-818b4bf8b354d43360e3fd9d0b10440636a25212.tar.bz2 | |
handle negative time value and prevent a divide by zero
| -rw-r--r-- | rest_framework/throttling.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/rest_framework/throttling.py b/rest_framework/throttling.py index a946d837..efa9fb94 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) |
