[Yum-devel] [PATCH 2/2] Simplify error handling when obtaining a lock

Zdeněk Pavlas zpavlas at redhat.com
Mon Aug 8 08:20:07 UTC 2011


Handle non-transient errors (EPERM, EACCES, ENOSPC) first.
---
 yummain.py |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/yummain.py b/yummain.py
index e2fe87b..d7ba288 100755
--- a/yummain.py
+++ b/yummain.py
@@ -120,16 +120,16 @@ def main(args):
             if exception2msg(e) != lockerr:
                 lockerr = exception2msg(e)
                 logger.critical(lockerr)
-            if (e.errno not in (errno.EPERM, errno.EACCES, errno.ENOSPC) and
-                not base.conf.exit_on_lock):
+            if e.errno in (errno.EPERM, errno.EACCES, errno.ENOSPC):
+                logger.critical(_("Can't create lock file; exiting"))
+                return 1
+
+            if not base.conf.exit_on_lock:
                 logger.critical(_("Another app is currently holding the yum lock; waiting for it to exit..."))
                 tm = 0.1
                 if show_lock_owner(e.pid, logger):
                     tm = 2
                 time.sleep(tm)
-            elif e.errno in (errno.EPERM, errno.EACCES, errno.ENOSPC):
-                logger.critical(_("Can't create lock file; exiting"))
-                return 1
             else:
                 logger.critical(_("Another app is currently holding the yum lock; exiting as configured by exit_on_lock"))
                 return 1
-- 
1.7.4.4



More information about the Yum-devel mailing list