From ad83fdec85e289974d591586383155aa71b10566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Sun, 27 Jul 2008 23:16:10 +0200 Subject: Make the updater parallel merge aware --- portato/gui/updater.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'portato/gui/updater.py') diff --git a/portato/gui/updater.py b/portato/gui/updater.py index ba46ffd..c4c81e7 100644 --- a/portato/gui/updater.py +++ b/portato/gui/updater.py @@ -27,8 +27,9 @@ class Updater (object): SED_EXP = r""" /\*/{ s/ \* // -q -}""" +n +} +d""" def __init__ (self, queue, iterators, threadClass = threading.Thread): """ @@ -48,6 +49,7 @@ q self.iterators = iterators self.threadClass = threadClass self.stopEvent = threading.Event() + self.removed = set() t = threadClass(name = "Queue Updater Thread", target = self.run) t.setDaemon(True) @@ -59,19 +61,21 @@ q Checks the packages until being stopped. """ - curr = None + curr = set() while not self.stopEvent.isSet(): # this = $(qlop -cCq | sed $SED_EXP) p1 = subprocess.Popen(["qlop", "--current", "--nocolor", "--quiet"], stdout = subprocess.PIPE) this = subprocess.Popen(["sed", self.SED_EXP], stdout = subprocess.PIPE, stdin = p1.stdout).communicate()[0] - if this: this = this.strip() - if this != curr: # changed package - curr and self.remove(self.find(curr)) # remove the previous - curr = this + this = set(this.split()) if this else set() + for removed in curr - this: + self.remove(self.find(removed)) # remove the previous + curr = this time.sleep(2.0) + + self.removed = set() def stop (self): """ @@ -111,6 +115,11 @@ q debug("Nothing to remove.") return + if cpv in self.removed: + return + + self.removed.add(cpv) + try: self.queue.remove_with_children(self.iterators[cpv]) except KeyError: -- cgit v1.2.3