Replace else-if with elif.
This commit is contained in:
parent
1d0f96a966
commit
9b8b0b6339
1 changed files with 9 additions and 8 deletions
|
@ -52,15 +52,16 @@ class Ratelimiter:
|
|||
if self.balance >= cost:
|
||||
self.balance -= cost
|
||||
successful = True
|
||||
|
||||
elif self.mode == 'reject':
|
||||
successful = False
|
||||
|
||||
else:
|
||||
if self.mode == 'reject':
|
||||
successful = False
|
||||
else:
|
||||
deficit = cost - self.balance
|
||||
time_needed = deficit / self.gain_rate
|
||||
time.sleep(time_needed)
|
||||
self.balance = 0
|
||||
successful = True
|
||||
deficit = cost - self.balance
|
||||
time_needed = deficit / self.gain_rate
|
||||
time.sleep(time_needed)
|
||||
self.balance = 0
|
||||
successful = True
|
||||
|
||||
self.last_operation = time.time()
|
||||
return successful
|
||||
|
|
Loading…
Reference in a new issue