Hi!
Recent timings showed that we populate the transaction object several times.
This was necessary in the past when we where working with predownloaded
headers but doesn't make sense anymore. I also realized that we call
ts.check twice (once in _run_rpm_check_debug and once before ts.order).
The attached patch is the first step to get things into order again. It adds
a .clearTsFlag() method to the Transaction object to set back the TEST flag
and moves the _run_rpm_check_debug() call into the area where the
.dsCallback is unset to get rid of the unsetting code in
_run_rpm_check_debug() itself.
The code paths in cli.py look good already. The code in __init__.py - that
is suposed to be used by 3rd party programs - is not that elaborated yet.
Can someone with a bit more "3rd party usage" experience look over the
patch, please?
Thanks
Florian
>From 7ad2ecd9bf67ba4882e1649d1ba9048c729c40b4 Mon Sep 17 00:00:00 2001
From: Florian Festi <[EMAIL PROTECTED]>
Date: Thu, 24 Jan 2008 16:00:47 +0100
Subject: [PATCH] Avoid population the transaction object over and over again
---
cli.py | 40 +++++++++++++++++-----------------------
rpmUtils/transaction.py | 8 +++++++-
yum/__init__.py | 26 +++++++++-----------------
3 files changed, 33 insertions(+), 41 deletions(-)
diff --git a/cli.py b/cli.py
index 581776a..bcf9fed 100644
--- a/cli.py
+++ b/cli.py
@@ -346,17 +346,23 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
if self.gpgsigcheck(downloadpkgs) != 0:
return 1
- if self.conf.rpm_check_debug:
- self.verbose_logger.log(yum.logginglevels.INFO_2,
- 'Running rpm_check_debug')
- msgs = self._run_rpm_check_debug()
- if msgs:
- print 'ERROR with rpm_check_debug vs depsolve:'
- for msg in msgs:
- print msg
+ # build transaction object
+ self.initActionTs()
+ # save our dsCallback out
+ dscb = self.dsCallback
+ self.dsCallback = None # dumb, dumb dumb dumb!
+ self.populateTs(keepold=0) # sigh
+
+ # required for ordering
+ self.verbose_logger.log(yum.logginglevels.INFO_2,
+ 'Running Transaction Check')
+ msgs = self._run_rpm_check_debug()
+ if msgs:
+ print 'ERROR with rpm_check_debug vs depsolve:'
+ for msg in msgs:
+ print msg
- return 1, ['Please report this error in bugzilla']
-
+ return 1, ['Please report this error in bugzilla']
self.verbose_logger.log(yum.logginglevels.INFO_2,
'Running Transaction Test')
@@ -364,15 +370,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
for feature in ['diskspacecheck']: # more to come, I'm sure
tsConf[feature] = getattr(self.conf, feature)
- testcb = RPMTransaction(self, test=True)
-
- self.initActionTs()
- # save our dsCallback out
- dscb = self.dsCallback
- self.dsCallback = None # dumb, dumb dumb dumb!
- self.populateTs(keepold=0) # sigh
- tserrors = self.ts.test(testcb, conf=tsConf)
- del testcb
+ tserrors = self.ts.test(RPMTransaction(self, test=True), conf=tsConf)
self.verbose_logger.log(yum.logginglevels.INFO_2,
'Finished Transaction Test')
@@ -385,14 +383,10 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
self.errorSummary(errstring)
self.verbose_logger.log(yum.logginglevels.INFO_2,
'Transaction Test Succeeded')
- del self.ts
# unset the sigquit handler
signal.signal(signal.SIGQUIT, signal.SIG_DFL)
- self.initActionTs() # make a new, blank ts to populate
- self.populateTs(keepold=0) # populate the ts
- self.ts.check() #required for ordering
self.ts.order() # order
# put back our depcheck callback
diff --git a/rpmUtils/transaction.py b/rpmUtils/transaction.py
index bb481e6..7049029 100644
--- a/rpmUtils/transaction.py
+++ b/rpmUtils/transaction.py
@@ -82,6 +82,10 @@ class TransactionWrapper:
def addTsFlag(self, flag):
curflags = self.ts.setFlags(0)
self.ts.setFlags(curflags | flag)
+
+ def clearTsFlag(self, flag):
+ curflags = self.ts.setFlags(0)
+ self.ts.setFlags(curflags & ~flag)
def test(self, cb, conf={}):
"""tests the ts we've setup, takes a callback function and a conf dict
@@ -96,7 +100,9 @@ class TransactionWrapper:
self.ts.setProbFilter(rpm.RPMPROB_FILTER_DISKSPACE)
tserrors = self.ts.run(cb.callback, '')
-
+
+ self.clearTsFlag(rpm.RPMTRANS_FLAG_TEST)
+
reserrors = []
if tserrors:
for (descr, (etype, mount, need)) in tserrors:
diff --git a/yum/__init__.py b/yum/__init__.py
index 8b198da..56b0fe5 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2545,6 +2545,14 @@ class YumBase(depsolve.Depsolve):
def _doTestTransaction(self,callback,display=None):
''' Do the RPM test transaction '''
# This can be overloaded by a subclass.
+
+ self.initActionTs()
+ # save our dsCallback out
+ dscb = self.dsCallback
+ self.dsCallback = None # dumb, dumb dumb dumb!
+ self.populateTs( keepold=0 ) # sigh
+ tserrors = self.ts.test( RPMTransaction(self, test=True), conf=tsConf )
+
if self.conf.rpm_check_debug:
self.verbose_logger.log(logginglevels.INFO_2,
'Running rpm_check_debug')
@@ -2558,21 +2566,10 @@ class YumBase(depsolve.Depsolve):
tsConf = {}
for feature in ['diskspacecheck']: # more to come, I'm sure
tsConf[feature] = getattr( self.conf, feature )
- #
- testcb = RPMTransaction(self, test=True)
+
# overwrite the default display class
if display:
testcb.display = display
- # clean out the ts b/c we have to give it new paths to the rpms
- del self.ts
-
- self.initActionTs()
- # save our dsCallback out
- dscb = self.dsCallback
- self.dsCallback = None # dumb, dumb dumb dumb!
- self.populateTs( keepold=0 ) # sigh
- tserrors = self.ts.test( testcb, conf=tsConf )
- del testcb
if len( tserrors ) > 0:
errstring = 'Test Transaction Errors: '
@@ -2601,10 +2598,6 @@ class YumBase(depsolve.Depsolve):
def _run_rpm_check_debug(self):
import rpm
results = []
- # save our dsCallback out
- dscb = self.dsCallback
- self.dsCallback = None # dumb, dumb dumb dumb!
- self.populateTs(test=1)
deps = self.ts.check()
for deptuple in deps:
((name, version, release), (needname, needversion), flags,
@@ -2619,6 +2612,5 @@ class YumBase(depsolve.Depsolve):
(name, rpmUtils.miscutils.formatRequire(needname,
needversion, flags))
results.append(msg)
- self.dsCallback = dscb
return results
--
1.5.3.3
_______________________________________________
Yum-devel mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel