diff --git a/r2/r2/lib/stats.py b/r2/r2/lib/stats.py index 7f5aaef40..aaadb10e5 100644 --- a/r2/r2/lib/stats.py +++ b/r2/r2/lib/stats.py @@ -53,8 +53,12 @@ class TimingStatBuffer: def flush(self): """Yields accumulated timing and counter data and resets the buffer.""" data, self.data = self.data, collections.defaultdict(complex) - while data: - k, v = data.popitem() + while True: + try: + k, v = data.popitem() + except KeyError: + break + total_time, count = v.real, v.imag yield k, str(int(count)) + '|c' divisor = count or 1