[yum-commits] yum-cron/yum-cron.py

zpavlas at osuosl.org zpavlas at osuosl.org
Mon Jan 20 10:42:31 UTC 2014


 yum-cron/yum-cron.py |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

New commits:
commit 8d21de54f5b267af8710c1358fd3a0475aed6bbb
Author: Zdenek Pavlas <zpavlas at redhat.com>
Date:   Mon Jan 20 11:41:15 2014 +0100

    yum-cron: Add a retry loop around doLock().

diff --git a/yum-cron/yum-cron.py b/yum-cron/yum-cron.py
index bfa580e..e1028be 100755
--- a/yum-cron/yum-cron.py
+++ b/yum-cron/yum-cron.py
@@ -262,6 +262,8 @@ class YumCronConfig(BaseConfig):
     system_name = Option(gethostname())
     output_width = IntOption(80)
     random_sleep = IntOption(0)
+    lock_retries = IntOption(5)
+    lock_sleep = IntOption(60)
     emit_via = ListOption(['email','stdio'])
     email_to = ListOption(["root"])
     email_from = Option("root")
@@ -386,9 +388,14 @@ class YumCronBase(yum.YumBase, YumOutput):
     def acquireLock(self):
         """ Wrapper method around doLock to emit errors correctly."""
 
-        try:
-            self.doLock()
-        except yum.Errors.LockError, e:
+        i = 0
+        while True:
+            try: self.doLock(); break
+            except yum.Errors.LockError, e:
+                i += 1
+                if i < self.opts.lock_retries:
+                    sleep(self.opts.lock_sleep)
+                    continue
             self.logger.warn("Failed to acquire the yum lock: %s", e)
             sys.exit(1)
 


More information about the Yum-commits mailing list