Replace else-if with elif.

This commit is contained in:
Ethan Dalool 2020-02-17 23:04:39 -08:00
parent 1d0f96a966
commit 9b8b0b6339

View file

@ -52,15 +52,16 @@ class Ratelimiter:
if self.balance >= cost: if self.balance >= cost:
self.balance -= cost self.balance -= cost
successful = True successful = True
elif self.mode == 'reject':
successful = False
else: else:
if self.mode == 'reject': deficit = cost - self.balance
successful = False time_needed = deficit / self.gain_rate
else: time.sleep(time_needed)
deficit = cost - self.balance self.balance = 0
time_needed = deficit / self.gain_rate successful = True
time.sleep(time_needed)
self.balance = 0
successful = True
self.last_operation = time.time() self.last_operation = time.time()
return successful return successful