From aa65ed729898304d7d1cc27ee1bf0d52094b810e Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Fri, 8 Aug 2008 10:02:38 +0000
Subject: [PATCH] Log only unexpected errors in utils.FileLock

Otherwise users might be confused by errors in log files.

Reviewed-by: iustinp
---
 lib/utils.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/utils.py b/lib/utils.py
index f263637d4..beee42835 100644
--- a/lib/utils.py
+++ b/lib/utils.py
@@ -1217,10 +1217,11 @@ class FileLock(object):
     try:
       fcntl.flock(self.fd, flag)
     except IOError, err:
-      logging.exception("fcntl.flock failed")
       if err.errno in (errno.EAGAIN, ):
         raise errors.LockError(errmsg)
-      raise
+      else:
+        logging.exception("fcntl.flock failed")
+        raise
 
   def Exclusive(self, blocking=False):
     """Locks the file in exclusive mode.
-- 
GitLab