From b6380e73f9800c7d14f8379248592b23d1a527d5 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 20 Nov 2008 21:55:35 +0000 Subject: 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 --- lib/thandy/ClientCLI.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'lib/thandy/ClientCLI.py') 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.") -- cgit v1.2.3