Commit ddfa05a4 authored by Benji York's avatar Benji York

fix a small bug in the file locking error logging

parent a8ce277c
...@@ -109,7 +109,15 @@ Bugs Fixed ...@@ -109,7 +109,15 @@ Bugs Fixed
- Fixed bug in ClientCache that occurred with objects larger than the total - Fixed bug in ClientCache that occurred with objects larger than the total
cache size. cache size.
3.8.1b8 (2008-09-??) 3.8.1b9 (2008-??-??)
====================
Bugs Fixed:
- When an error occured attempting to lock a file and logging of said error was
enabled.
3.8.1b8 (2008-09-22
==================== ====================
Bugs Fixed: Bugs Fixed:
......
...@@ -82,7 +82,9 @@ class LockFile: ...@@ -82,7 +82,9 @@ class LockFile:
fp.seek(1) fp.seek(1)
pid = fp.read().strip()[:20] pid = fp.read().strip()[:20]
fp.close() 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 raise
self._fp = fp self._fp = fp
......
...@@ -9,14 +9,20 @@ LockFile object with a file name: ...@@ -9,14 +9,20 @@ LockFile object with a file name:
>>> import ZODB.lock_file >>> import ZODB.lock_file
>>> lock = ZODB.lock_file.LockFile('lock') >>> 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: >>> try:
... ZODB.lock_file.LockFile('lock') ... ZODB.lock_file.LockFile('lock')
... except ZODB.lock_file.LockError: ... except ZODB.lock_file.LockError:
... print "Can't lock file" ... print "Can't lock file"
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: To release the lock, use it's close method:
>>> lock.close() >>> 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