From f129c4c073ae5884629f0f7c0e4252b11198a7c2 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 20 Jun 2010 17:07:29 +0100 Subject: [PATCH] fetch_candidates doesn't have to be async --- tests/testdistro.py | 8 ++------ zeroinstall/injector/distro.py | 8 +++----- zeroinstall/injector/fetch.py | 5 +++-- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/tests/testdistro.py b/tests/testdistro.py index cb56f42..03a37c3 100755 --- a/tests/testdistro.py +++ b/tests/testdistro.py @@ -86,12 +86,8 @@ class TestDistro(BaseTest): master_feed = parse_impls("""""") h = handler.Handler() candidates = host.fetch_candidates(master_feed) - # Async, so nothing yet... - self.feed = model.ZeroInstallFeed(empty_feed, local_path = '/empty.xml') - host.get_package_info('python-bittorrent', factory) - self.assertEquals(1, len(self.feed.implementations)) - - h.wait_for_blocker(candidates) + if candidates: + h.wait_for_blocker(candidates) # Now we see the uninstalled package self.feed = model.ZeroInstallFeed(empty_feed, local_path = '/empty.xml') host.get_package_info('python-bittorrent', factory) diff --git a/zeroinstall/injector/distro.py b/zeroinstall/injector/distro.py index 6039a01..36b78f6 100644 --- a/zeroinstall/injector/distro.py +++ b/zeroinstall/injector/distro.py @@ -205,12 +205,12 @@ class Distribution(object): self.get_package_info(package, factory) return feed - @tasks.async def fetch_candidates(self, master_feed): """Collect information about versions we could install using the distribution's package manager. On success, the distribution - feed in iface_cache is updated.""" - yield + feed in iface_cache is updated. + @return: a L{tasks.Blocker} if the task is in progress, or None if not""" + pass class CachedDistribution(Distribution): """For distributions where querying the package database is slow (e.g. requires running @@ -387,10 +387,8 @@ class DebianDistribution(Distribution): installed_id = 'package:deb:%s:%s' % (package, installed_version) return package_id == installed_id - @tasks.async def fetch_candidates(self, master_feed): package_names = [item.getAttribute("package") for item, item_attrs in master_feed.get_package_impls(self)] - yield for package in package_names: # Check to see whether we could get a newer version using apt-get diff --git a/zeroinstall/injector/fetch.py b/zeroinstall/injector/fetch.py index e651296..2519bd1 100644 --- a/zeroinstall/injector/fetch.py +++ b/zeroinstall/injector/fetch.py @@ -163,8 +163,9 @@ class Fetcher(object): master_feed = iface_cache.get_feed(feed_url.split(':', 1)[1]) if master_feed: fetch = iface_cache.distro.fetch_candidates(master_feed) - yield fetch - tasks.check(fetch) + if fetch: + yield fetch + tasks.check(fetch) # Force feed to be regenerated with the new information iface_cache.get_feed(feed_url, force = True) -- 2.11.4.GIT