From f2a33c7c2fef7a8266e3a5753e3ae573b873264e Mon Sep 17 00:00:00 2001 From: Zdenek Pavlas Date: Tue, 1 Oct 2013 15:25:05 +0200 Subject: clamp timestamps from the future. BZ 894630, 1013733 The previous fix was incomplete. Only update() path was fixed, but not the estimate() path. By moving the code that clamps timestamps to the loader, we fix both. --- urlgrabber/grabber.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'urlgrabber') diff --git a/urlgrabber/grabber.py b/urlgrabber/grabber.py index 63baef7..9252977 100644 --- a/urlgrabber/grabber.py +++ b/urlgrabber/grabber.py @@ -2355,9 +2355,10 @@ class _TH: filename = default_grabber.opts.timedhosts if filename and _TH.dirty is None: try: + now = int(time.time()) for line in open(filename): host, speed, fail, ts = line.rsplit(' ', 3) - _TH.hosts[host] = int(speed), int(fail), int(ts) + _TH.hosts[host] = int(speed), int(fail), min(int(ts), now) except IOError: pass _TH.dirty = False @@ -2389,9 +2390,6 @@ class _TH: if ug_err is None: # defer first update if the file was small. BZ 851178. if not ts and dl_size < 1e6: return - # clamp timestamps from the future. BZ 894630. - if ts > now: ts = now - # k1: the older, the less useful # k2: <500ms readings are less reliable # speeds vary, use 10:1 smoothing -- cgit v1.2.1