mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-03-27 13:24:26 +03:00
handle negative time value and prevent a divide by zero
This commit is contained in:
parent
6e92e415aa
commit
818b4bf8b3
|
@ -136,6 +136,8 @@ class SimpleRateThrottle(BaseThrottle):
|
||||||
remaining_duration = self.duration
|
remaining_duration = self.duration
|
||||||
|
|
||||||
available_requests = self.num_requests - len(self.history) + 1
|
available_requests = self.num_requests - len(self.history) + 1
|
||||||
|
if available_requests <= 0:
|
||||||
|
return None
|
||||||
|
|
||||||
return remaining_duration / float(available_requests)
|
return remaining_duration / float(available_requests)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user