[issue237] smart hangs when upgrading the whole system

so at Labix Tracker tracker at labix.org
Sat Oct 28 16:43:57 PDT 2006


so <so at lalisio.com> added the comment:

okay, i found something that prevents the hang, but i'm not sure if the result 
is correct. with a print statement and some counters here and there i got the 
impression that many packages where checked over and over again. i have no 
idea if this is necessary, shouldn't one check be enough? 

my solution is a global counter for already "inspected" packages, and a 
condition in the _pending() method: if a package is about to be checked again 
for the same operation, just skip it. the calculation for the whole upgrade 
seems to becomes pretty fast that way :-)

--- smart/transaction.py        2006-10-29 00:28:50.000000000 +0200
+++ /usr/lib64/python2.4/site-packages/smart/transaction.py     2006-10-29 
01:39:44.000000000 +0200
@@ -394,6 +394,16 @@

 class Failed(Error): pass

+class InspectCounter(dict):
+
+    def add(self, name):
+        self.setdefault(name, 0)
+        self[name] += 1
+        return self[name]
+
+ic = InspectCounter()
+
+
 PENDING_REMOVE   = 1
 PENDING_INSTALL  = 2
 PENDING_UPDOWN   = 3
@@ -699,6 +709,12 @@
         while pending:
             item = pending.pop(0)
             kind = item[0]
+
+            iccount = ic.add('%s %s' % (item[1], kind))
+            if iccount > 1:
+                continue
+            print '_pending() inspecting', item[1], iccount, kind
+
             if kind == PENDING_UPDOWN:
                 updown.append(item[1])
             elif kind == PENDING_INSTALL:


now, could someone tell me if this is a valid fix or not?

_______________________________________
Labix issue tracker <tracker at labix.org>
<http://tracker.labix.org/issue237>
_______________________________________



More information about the Smart mailing list