[Yum-devel] [PATCH] add exit_on_lock option for rh bug https://bugzilla.redhat.com/show_bug.cgi?id=598527

Seth Vidal skvidal at fedoraproject.org
Tue Jun 1 19:14:46 UTC 2010


if the lock is held, exit with value and output
updated utils.py for this as well.

settable on the cli with --setopt=...
---
 utils.py      |    9 ++++++---
 yum/config.py |    3 ++-
 yummain.py    |   10 +++++++---
 3 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/utils.py b/utils.py
index 1bb4569..b5b38bd 100644
--- a/utils.py
+++ b/utils.py
@@ -154,9 +154,12 @@ class YumUtilBase(YumBaseCli):
                 if "%s" %(e.msg,) != lockerr:
                     lockerr = "%s" %(e.msg,)
                     self.logger.critical(lockerr)
-                self.logger.critical("Another app is currently holding the yum lock; waiting for it to exit...")  
-                show_lock_owner(e.pid, self.logger)
-                time.sleep(2)
+                if not self.conf.exit_on_lock:
+                    self.logger.critical("Another app is currently holding the yum lock; waiting for it to exit...")  
+                    show_lock_owner(e.pid, self.logger)
+                    time.sleep(2)
+                else:
+                    raise Errors.YumBaseError, _("Another app is currently holding the yum lock; exiting as configured by exit_on_lock")
             else:
                 break
         
diff --git a/yum/config.py b/yum/config.py
index 949751a..11347a6 100644
--- a/yum/config.py
+++ b/yum/config.py
@@ -735,7 +735,8 @@ class YumConf(StartupConf):
 
     protected_packages = ListOption("yum, glob:/etc/yum/protected.d/*.conf",
                                     parse_default=True)
-
+    exit_on_lock = BoolOption(False)
+    
     _reposlist = []
 
     def dump(self):
diff --git a/yummain.py b/yummain.py
index 305e0c7..95c7462 100755
--- a/yummain.py
+++ b/yummain.py
@@ -99,9 +99,13 @@ def main(args):
             if "%s" %(e.msg,) != lockerr:
                 lockerr = "%s" %(e.msg,)
                 logger.critical(lockerr)
-            logger.critical(_("Another app is currently holding the yum lock; waiting for it to exit..."))
-            show_lock_owner(e.pid, logger)
-            time.sleep(2)
+            if not base.conf.exit_on_lock:
+                logger.critical(_("Another app is currently holding the yum lock; waiting for it to exit..."))
+                show_lock_owner(e.pid, logger)
+                time.sleep(2)
+            else:
+                logger.critical(_("Another app is currently holding the yum lock; exiting as configured by exit_on_lock"))
+                return 1
         else:
             break
 
-- 
1.7.0.1



More information about the Yum-devel mailing list