[Yum-devel] [PATCH] Add and document the 'low_speed_limit' option.

Zdeněk Pavlas zpavlas at redhat.com
Tue Sep 25 12:31:16 UTC 2012


---
 urlgrabber/grabber.py |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/urlgrabber/grabber.py b/urlgrabber/grabber.py
index 2ba3603..6956a59 100644
--- a/urlgrabber/grabber.py
+++ b/urlgrabber/grabber.py
@@ -92,6 +92,11 @@ GENERAL ARGUMENTS (kwargs)
     the curl documentation on CURLOPT_CONNECTTIMEOUT for more information.
     http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTCONNECTTIMEOUT
 
+  low_speed_limit = 1
+
+    a minimum bytes/second limit.  If the download speed falls below
+    this threshold for more than timeout seconds, download is aborted.
+
   bandwidth = 0
 
     the nominal max bandwidth in bytes/second.  If throttle is a float
@@ -946,6 +951,7 @@ class URLGrabberOptions:
         self.opener = None
         self.cache_openers = True
         self.timeout = 300
+        self.low_speed_limit = 1
         self.text = None
         self.http_headers = None
         self.ftp_headers = None
@@ -1364,7 +1370,7 @@ class PyCurlFileObject(object):
         if hasattr(opts, 'timeout'):
             timeout = int(opts.timeout or 0)
         self.curl_obj.setopt(pycurl.CONNECTTIMEOUT, timeout)
-        self.curl_obj.setopt(pycurl.LOW_SPEED_LIMIT, 1)
+        self.curl_obj.setopt(pycurl.LOW_SPEED_LIMIT, opts.low_speed_limit)
         self.curl_obj.setopt(pycurl.LOW_SPEED_TIME, timeout)
 
         # ssl options
@@ -2038,6 +2044,7 @@ class _ExternalDownloader:
         'throttle', 'bandwidth', 'range', 'reget',
         'user_agent', 'http_headers', 'ftp_headers',
         'proxy', 'prefix', 'username', 'password',
+        'low_speed_limit',
         'ssl_ca_cert',
         'ssl_cert', 'ssl_cert_type',
         'ssl_key', 'ssl_key_type',
-- 
1.7.4.4



More information about the Yum-devel mailing list