diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-11-20 21:55:35 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-11-20 21:55:35 +0000 |
commit | b6380e73f9800c7d14f8379248592b23d1a527d5 (patch) | |
tree | 8595c508d1997878ca7b81d2097a80048d6187b4 /lib/thandy/ClientCLI.py | |
parent | d5e5a118facc833ed4b1984b0a5721e1509c576a (diff) |
Teach thandy downloader how to back off on failure, ignore failing mirrors for a while, etc. still needs to be taught to persist this info, if that seems smart.
git-svn-id: file:///home/or/svnrepo/updater/trunk@17339 55e972cd-5a19-0410-ae62-a4d7a52db4cd
Diffstat (limited to 'lib/thandy/ClientCLI.py')
-rw-r--r-- | lib/thandy/ClientCLI.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/thandy/ClientCLI.py b/lib/thandy/ClientCLI.py index 55d52c6..68be6a1 100644 --- a/lib/thandy/ClientCLI.py +++ b/lib/thandy/ClientCLI.py @@ -61,6 +61,9 @@ def update(args): if use_packagesys: packagesys = thandy.packagesys.PackageSystem.PackageMetasystem.create(repo) + downloader = thandy.download.DownloadManager() + downloader.start() + # XXXX We could make this loop way smarter. Right now, it doesn't # back off between failures, and it doesn't notice newly downloadable files # until all downloading files are finished. @@ -110,9 +113,24 @@ def update(args): if not mirrorlist: mirrorlist = thandy.master_keys.DEFAULT_MIRRORLIST - downloader = thandy.download.DownloadManager() + if files: + waitTill = min(downloader.getRetryTime(mirrorlist, f) + for f in files) + now = time.time() + if waitTill > now: + delay = int(waitTill - now) + 1 + logging.info("Waiting another %s seconds before we are willing " + "to retry any mirror.", delay) + time.sleep(delay) + continue + logging.debug("Launching downloads") + now = time.time() for f in files: + if downloader.getRetryTime(mirrorlist, f) > now: + logging.info("Waiting a while before we fetch %s", f) + continue + dj = thandy.download.ThandyDownloadJob( f, repo.getFilename(f), mirrorlist, @@ -130,9 +148,6 @@ def update(args): downloader.addDownloadJob(dj) - logging.debug("Launching downloads") - downloader.start() - logging.debug("Waiting for downloads to finish.") downloader.wait() logging.info("All downloads finished.") |