From 6256ec6a07b1d402def96d02cfb5bff0f260f823 Mon Sep 17 00:00:00 2001 From: Noah Levitt Date: Tue, 29 May 2018 13:08:34 -0700 Subject: [PATCH] add another "wait" to fix failing test --- tests/test_warcprox.py | 3 +++ warcprox/stats.py | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_warcprox.py b/tests/test_warcprox.py index 0deecc6..13b6bad 100755 --- a/tests/test_warcprox.py +++ b/tests/test_warcprox.py @@ -726,6 +726,9 @@ def test_limits(http_daemon, warcprox_, archiving_proxies): assert response.headers['warcprox-test-header'] == 'i!' assert response.content == b'I am the warcprox test payload! jjjjjjjjjj!\n' + # wait for postfetch chain + wait(lambda: warcprox_.proxy.running_stats.urls - urls_before == 11) + def test_return_capture_timestamp(http_daemon, warcprox_, archiving_proxies): urls_before = warcprox_.proxy.running_stats.urls diff --git a/warcprox/stats.py b/warcprox/stats.py index 85539e2..64ff2d7 100644 --- a/warcprox/stats.py +++ b/warcprox/stats.py @@ -309,11 +309,9 @@ class RunningStats: need_ten_sec_snap = (now - self.ten_sec_snaps[0][0]) // 10 > (self.ten_sec_snaps[-1][0] - self.ten_sec_snaps[0][0]) // 10 if need_minute_snap: self.minute_snaps.append((now, self.urls, self.warc_bytes)) - logging.debug('added minute snap %r', self.minute_snaps[-1]) if need_ten_sec_snap: self.ten_sec_snaps.popleft() self.ten_sec_snaps.append((now, self.urls, self.warc_bytes)) - logging.trace('rotated in ten second snap %r', self.ten_sec_snaps[-1]) def _closest_ten_sec_snap(self, t): # it's a deque so iterating over it is faster than indexed lookup