[Yum-devel] [PATCH 1/2] Handle ENOSPC when creating a lock file.

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


Instead of printing a traceback, just print an error message.
Resolves BZ 728847.
---
 yum/__init__.py |    7 +++----
 yummain.py      |    4 ++--
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/yum/__init__.py b/yum/__init__.py
index b29dc80..4f90af4 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1838,16 +1838,15 @@ class YumBase(depsolve.Depsolve):
             if not os.path.exists(lockdir):
                 os.makedirs(lockdir, mode=0755)
             fd = os.open(filename, os.O_EXCL|os.O_CREAT|os.O_WRONLY, mode)    
+            os.write(fd, contents)
+            os.close(fd)
+            return 1
         except OSError, msg:
             if not msg.errno == errno.EEXIST: 
                 # Whoa. What the heck happened?
                 errmsg = _('Could not create lock at %s: %s ') % (filename, str(msg))
                 raise Errors.LockError(msg.errno, errmsg, int(contents))
             return 0
-        else:
-            os.write(fd, contents)
-            os.close(fd)
-            return 1
     
     def _unlock(self, filename):
         misc.unlink_f(filename)
diff --git a/yummain.py b/yummain.py
index d6abd70..e2fe87b 100755
--- a/yummain.py
+++ b/yummain.py
@@ -120,14 +120,14 @@ def main(args):
             if exception2msg(e) != lockerr:
                 lockerr = exception2msg(e)
                 logger.critical(lockerr)
-            if (e.errno not in (errno.EPERM, errno.EACCES) and
+            if (e.errno not in (errno.EPERM, errno.EACCES, errno.ENOSPC) and
                 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):
+            elif e.errno in (errno.EPERM, errno.EACCES, errno.ENOSPC):
                 logger.critical(_("Can't create lock file; exiting"))
                 return 1
             else:
-- 
1.7.4.4



More information about the Yum-devel mailing list