timedhosts: sanity check on dl_time

epel9
Zdeněk Pavlas 13 years ago
parent 88126d0a23
commit 4cd10e5be9

@ -63,3 +63,35 @@ index 094be77..be85f92 100644
default_speed = default_grabber.opts.default_speed
try: speed, fail, ts = _TH.hosts[host]
except KeyError: return default_speed
commit fa6a17c29e9dea3ccd2d384039b305f027a5b75e
Author: Zdeněk Pavlas <zpavlas@redhat.com>
Date: Mon May 21 09:06:13 2012 +0200
timedhosts: sanity check on dl_time
- handle the dl_time <= 0 case
- relative validity of calculated speed now depends
on dl_time instead of dl_size. (that's where the
random error is)
diff --git a/urlgrabber/grabber.py b/urlgrabber/grabber.py
index be85f92..73e14aa 100644
--- a/urlgrabber/grabber.py
+++ b/urlgrabber/grabber.py
@@ -2301,11 +2301,12 @@ class _TH:
if ug_err is None:
# k1: the older, the less useful
- # k2: if it was <1MiB, don't trust it much
+ # k2: <500ms readings are less reliable
# speeds vary, use 10:1 smoothing
k1 = 2**((ts - now) / default_grabber.opts.half_life)
- k2 = min(dl_size / 1e6, 1.0) / 10
- speed = (k1 * speed + k2 * dl_size / dl_time) / (k1 + k2)
+ k2 = min(dl_time / .500, 1.0) / 10
+ if k2 > 0:
+ speed = (k1 * speed + k2 * dl_size / dl_time) / (k1 + k2)
fail = 0
elif getattr(ug_err, 'code', None) == 404:
fail = 0 # alive, at least

@ -3,7 +3,7 @@
Summary: A high-level cross-protocol url-grabber
Name: python-urlgrabber
Version: 3.9.1
Release: 13%{?dist}
Release: 14%{?dist}
Source0: urlgrabber-%{version}.tar.gz
Patch1: urlgrabber-HEAD.patch
Patch2: multi-downloader.patch
@ -48,6 +48,9 @@ rm -rf $RPM_BUILD_ROOT
%attr(0755,root,root) /usr/libexec/urlgrabber-ext-down
%changelog
* Mon May 21 2012 Zdeněk Pavlas <zpavlas@redhat.com> - 3.9.1-14
- timedhosts: sanity check on dl_time
* Fri May 18 2012 Zdeněk Pavlas <zpavlas@redhat.com> - 3.9.1-13
- fix file:// profiling. BZ 822632.

Loading…
Cancel
Save