From 674e65488b2deb352eb0f683a139f133c48b9039 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 17 Apr 2011 17:11:02 +0100 Subject: [PATCH] Fixed bug when using PackageKit to query multiple packages at once Error reported was "KeyError: Task(fetch_candidates)" --- zeroinstall/injector/packagekit.py | 4 +++- zeroinstall/support/tasks.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/zeroinstall/injector/packagekit.py b/zeroinstall/injector/packagekit.py index 82c86d0..617ecfc 100644 --- a/zeroinstall/injector/packagekit.py +++ b/zeroinstall/injector/packagekit.py @@ -86,7 +86,9 @@ class PackageKit(object): assert self.pk known = [self._candidates[p] for p in package_names if p in self._candidates] - in_progress = [b for b in known if isinstance(b, tasks.Blocker)] + # (use set because a single task may be checking multiple packages and we need + # to avoid duplicates). + in_progress = list(set([b for b in known if isinstance(b, tasks.Blocker)])) _logger_pk.debug('Already downloading: %s', in_progress) # Filter out the ones we've already fetched diff --git a/zeroinstall/support/tasks.py b/zeroinstall/support/tasks.py index 302b0ee..44f85c5 100644 --- a/zeroinstall/support/tasks.py +++ b/zeroinstall/support/tasks.py @@ -137,6 +137,7 @@ class Blocker: """Called by the schedular when a Task yields this Blocker. If you override this method, be sure to still call this method with Blocker.add_task(self)!""" + assert task not in self._zero_lib_tasks, "Blocking on a single task twice: %s (%s)" % (task, self) self._zero_lib_tasks.add(task) def remove_task(self, task): -- 2.11.4.GIT