[Zodb-checkins] SVN: ZODB/branches/3.8/ fix a small bug in the file locking error logging

Benji York benji at zope.com
Fri Sep 26 15:19:59 EDT 2008


Log message for revision 91534:
  fix a small bug in the file locking error logging
  

Changed:
  U   ZODB/branches/3.8/NEWS.txt
  U   ZODB/branches/3.8/src/ZODB/lock_file.py
  U   ZODB/branches/3.8/src/ZODB/lock_file.txt

-=-
Modified: ZODB/branches/3.8/NEWS.txt
===================================================================
--- ZODB/branches/3.8/NEWS.txt	2008-09-26 19:07:56 UTC (rev 91533)
+++ ZODB/branches/3.8/NEWS.txt	2008-09-26 19:19:59 UTC (rev 91534)
@@ -4,6 +4,9 @@
 
 Bugs Fixed:
 
+- (beta 9) An exception would be raised when an error occured attempting to
+  lock a file and logging of said error was enabled.
+
 - (beta 9) Fixed a bug to allow opening of deep-copied blobs.
 
 - (beta 9) Fixed bug #189542 by prepending the module to an undefined name.

Modified: ZODB/branches/3.8/src/ZODB/lock_file.py
===================================================================
--- ZODB/branches/3.8/src/ZODB/lock_file.py	2008-09-26 19:07:56 UTC (rev 91533)
+++ ZODB/branches/3.8/src/ZODB/lock_file.py	2008-09-26 19:19:59 UTC (rev 91534)
@@ -82,7 +82,9 @@
             fp.seek(1)
             pid = fp.read().strip()[:20]
             fp.close()
-            logger.exception("Error locking file", path, pid)
+            if not pid:
+                pid = 'UNKNOWN'
+            logger.exception("Error locking file %s; pid=%s", path, pid)
             raise
 
         self._fp = fp

Modified: ZODB/branches/3.8/src/ZODB/lock_file.txt
===================================================================
--- ZODB/branches/3.8/src/ZODB/lock_file.txt	2008-09-26 19:07:56 UTC (rev 91533)
+++ ZODB/branches/3.8/src/ZODB/lock_file.txt	2008-09-26 19:19:59 UTC (rev 91534)
@@ -9,14 +9,20 @@
     >>> import ZODB.lock_file
     >>> lock = ZODB.lock_file.LockFile('lock')
 
-If we try to lock the same name, we'll get a lock error:
+If we try to lock the same name, we'll get a lock error and it will be logged:
 
+    >>> import ZODB.tests.loggingsupport
+    >>> handler = ZODB.tests.loggingsupport.InstalledHandler('ZODB.lock_file')
     >>> try:
     ...     ZODB.lock_file.LockFile('lock')
     ... except ZODB.lock_file.LockError:
     ...     print "Can't lock file"
     Can't lock file
 
+    >>> for record in handler.records:
+    ...     print record.levelname, record.getMessage()
+    ERROR Error locking file lock; pid=UNKNOWN
+
 To release the lock, use it's close method:
 
     >>> lock.close()



More information about the Zodb-checkins mailing list