summaryrefslogtreecommitdiff
path: root/portato/gui/updater.py
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2008-07-27 23:16:10 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2008-07-27 23:16:10 +0200
commitad83fdec85e289974d591586383155aa71b10566 (patch)
treed0604a4a323d4cabedbe96931d77d8767daae204 /portato/gui/updater.py
parent889f9c6a92e2744a67d056ef4f0a7ccd93673670 (diff)
downloadportato-ad83fdec85e289974d591586383155aa71b10566.tar.gz
portato-ad83fdec85e289974d591586383155aa71b10566.tar.bz2
portato-ad83fdec85e289974d591586383155aa71b10566.zip
Make the updater parallel merge aware
Diffstat (limited to 'portato/gui/updater.py')
-rw-r--r--portato/gui/updater.py23
1 files changed, 16 insertions, 7 deletions
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: