[Yum-devel] [PATCH 2/4] queue 'po's, not callbacks

Zdenek Pavlas zpavlas at redhat.com
Mon Apr 8 15:08:19 UTC 2013


---
 yum/drpm.py | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/yum/drpm.py b/yum/drpm.py
index d3f296d..dec4044 100644
--- a/yum/drpm.py
+++ b/yum/drpm.py
@@ -239,31 +239,26 @@ class DeltaInfo:
             # urlgrabber spawns child jobs, too.  But they exit synchronously,
             # so we should never see an unknown pid here.
             assert pid in self.jobs
-            callback = self.jobs.pop(pid)
-            callback(code)
+            po = self.jobs.pop(pid)
+            if code != 0:
+                unlink_f(po.rpm.localpath)
+                self.adderror(po, _('Delta RPM rebuild failed'))
+            elif not po.rpm.verifyLocalPkg():
+                self.adderror(po, _('Checksum of the delta-rebuilt RPM failed'))
+            else:
+                os.unlink(po.localpath)
+                po.localpath = po.rpm.localpath # for --downloadonly
             num += 1
         return num
 
     def rebuild(self, po):
         """ Turn a drpm into an rpm, by adding it to the queue and trying to
             service the queue. """
-        # this runs when worker finishes
-        def callback(code):
-            if code != 0:
-                unlink_f(po.rpm.localpath)
-                self.adderror(po, _('Delta RPM rebuild failed'))
-                return
-            if not po.rpm.verifyLocalPkg():
-                self.adderror(po, _('Checksum of the delta-rebuilt RPM failed'))
-                return
-            os.unlink(po.localpath)
-            po.localpath = po.rpm.localpath # for --downloadonly
-
         args = ()
         if po.oldrpm: args += '-r', po.oldrpm
         args += po.localpath, po.rpm.localpath
 
-        self.queue(args, callback)
+        self.queue(args, po)
         self.dequeue_max()
 
     def queue(self, args, callback):
-- 
1.7.11.7



More information about the Yum-devel mailing list