Commit bd80869d authored by Benji York's avatar Benji York

fix a small bug in the file locking error logging

parent edbbc85d
......@@ -4,6 +4,9 @@ Whats new in ZODB 3.8.1
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.
......
......@@ -82,7 +82,9 @@ class LockFile:
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
......
......@@ -9,14 +9,20 @@ LockFile object with a file name:
>>> 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()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment