mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-25 06:48:01 -05:00
stats.Timer: don't send intermediates immediately.
This allows us to change the base name of the timer before stop/flush is called and have the intermediates update as well.
This commit is contained in:
@@ -1505,4 +1505,6 @@ def process_votes(qname, limit=0):
|
||||
handle_vote(voter, votee, dir, ip, organic,
|
||||
cheater = cheater, foreground=True, timer=timer)
|
||||
|
||||
timer.flush()
|
||||
|
||||
amqp.consume_items(qname, _handle_vote, verbose = False)
|
||||
|
||||
@@ -163,6 +163,12 @@ class Timer:
|
||||
self._start = None
|
||||
self._last = None
|
||||
self._stop = None
|
||||
self._timings = []
|
||||
|
||||
def flush(self):
|
||||
for timing in self._timings:
|
||||
self.send(*timing)
|
||||
self._timings = []
|
||||
|
||||
def elapsed_seconds(self):
|
||||
if self._start is None:
|
||||
@@ -184,7 +190,7 @@ class Timer:
|
||||
if self._stop is not None:
|
||||
raise AssertionError("timer is stopped")
|
||||
last, self._last = self._last, self._time()
|
||||
self.send(subname, self._last - last)
|
||||
self._timings.append((subname, self._last - last))
|
||||
|
||||
def stop(self, subname='total'):
|
||||
if self._start is None:
|
||||
@@ -192,6 +198,7 @@ class Timer:
|
||||
if self._stop is not None:
|
||||
raise AssertionError('timer is already stopped')
|
||||
self._stop = self._time()
|
||||
self.flush()
|
||||
self.send(subname, self._stop - self._start)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user