timedhosts: defer 1st update until a 1MB+ download. BZ 851178

epel9
Zdeněk Pavlas 13 years ago
parent 5228c98fd8
commit 06d3b13e99

@ -3,7 +3,7 @@
Summary: A high-level cross-protocol url-grabber Summary: A high-level cross-protocol url-grabber
Name: python-urlgrabber Name: python-urlgrabber
Version: 3.9.1 Version: 3.9.1
Release: 18%{?dist} Release: 19%{?dist}
Source0: urlgrabber-%{version}.tar.gz Source0: urlgrabber-%{version}.tar.gz
Patch1: urlgrabber-HEAD.patch Patch1: urlgrabber-HEAD.patch
@ -44,6 +44,9 @@ rm -rf $RPM_BUILD_ROOT
%attr(0755,root,root) %{_libexecdir}/urlgrabber-ext-down %attr(0755,root,root) %{_libexecdir}/urlgrabber-ext-down
%changelog %changelog
* Mon Aug 27 2012 Zdeněk Pavlas <zpavlas@redhat.com> - 3.9.1-19
- timedhosts: defer 1st update until a 1MB+ download. BZ 851178
* Wed Aug 22 2012 Zdeněk Pavlas <zpavlas@redhat.com> - 3.9.1-18 * Wed Aug 22 2012 Zdeněk Pavlas <zpavlas@redhat.com> - 3.9.1-18
- Update to latest HEAD, lots of enhancements. - Update to latest HEAD, lots of enhancements.

@ -233,7 +233,7 @@ index 3e5f3b7..8eeaeda 100644
return (fb,lb) return (fb,lb)
diff --git a/urlgrabber/grabber.py b/urlgrabber/grabber.py diff --git a/urlgrabber/grabber.py b/urlgrabber/grabber.py
index e090e90..ffd5a10 100644 index e090e90..daa478d 100644
--- a/urlgrabber/grabber.py --- a/urlgrabber/grabber.py
+++ b/urlgrabber/grabber.py +++ b/urlgrabber/grabber.py
@@ -49,11 +49,26 @@ GENERAL ARGUMENTS (kwargs) @@ -49,11 +49,26 @@ GENERAL ARGUMENTS (kwargs)
@ -1225,7 +1225,7 @@ index e090e90..ffd5a10 100644
##################################################################### #####################################################################
# DEPRECATED FUNCTIONS # DEPRECATED FUNCTIONS
@@ -1621,6 +1924,458 @@ def retrygrab(url, filename=None, copy_local=0, close_connection=0, @@ -1621,6 +1924,460 @@ def retrygrab(url, filename=None, copy_local=0, close_connection=0,
##################################################################### #####################################################################
@ -1637,17 +1637,19 @@ index e090e90..ffd5a10 100644
+ +
+ @staticmethod + @staticmethod
+ def update(url, dl_size, dl_time, ug_err, baseurl=None): + def update(url, dl_size, dl_time, ug_err, baseurl=None):
+ _TH.load()
+
+ # Use hostname from URL. If it's a file:// URL, use baseurl. + # Use hostname from URL. If it's a file:// URL, use baseurl.
+ # If no baseurl, do not update timedhosts. + # If no baseurl, do not update timedhosts.
+ host = urlparse.urlsplit(url).netloc.split('@')[-1] or baseurl + host = urlparse.urlsplit(url).netloc.split('@')[-1] or baseurl
+ if not host: return + if not host: return
+ +
+ _TH.load()
+ speed, fail, ts = _TH.hosts.get(host) or (0, 0, 0) + speed, fail, ts = _TH.hosts.get(host) or (0, 0, 0)
+ now = time.time() + now = time.time()
+ +
+ if ug_err is None: + if ug_err is None:
+ # defer first update if the file was small. BZ 851178.
+ if not ts and dl_size < 1e6: return
+
+ # k1: the older, the less useful + # k1: the older, the less useful
+ # k2: <500ms readings are less reliable + # k2: <500ms readings are less reliable
+ # speeds vary, use 10:1 smoothing + # speeds vary, use 10:1 smoothing

Loading…
Cancel
Save