From bdfb02ed4456d68ffefceecb5372950d940429a7 Mon Sep 17 00:00:00 2001 From: Igor Chubin Date: Fri, 5 Oct 2018 16:51:25 +0200 Subject: [PATCH] minor cleanup --- bin/srv.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bin/srv.py b/bin/srv.py index 5c2b122..65c6078 100644 --- a/bin/srv.py +++ b/bin/srv.py @@ -96,12 +96,15 @@ class Limits: "Not so fast! Number of queries per %s is limited to %s" % (interval, self.limit[interval])) - def clear_counters( self ): - t = int( time.time() ) + def clear_counters(self): + """ + Initialize counters for new interval + """ + t_int = int(time.time()) for interval in self.intervals: - if t / self.divisor[interval] != self.last_update[interval]: + if t_int / self.divisor[interval] != self.last_update[interval]: self.counter[interval] = {} - self.last_update[interval] = t / self.divisor[interval] + self.last_update[interval] = t_int / self.divisor[interval] limits = Limits()