[Zodb-checkins] CVS: ZODB3/ZODB - lock_file.py:1.7
Jeremy Hylton
jeremy@zope.com
Tue, 3 Dec 2002 13:49:34 -0500
Update of /cvs-repository/ZODB3/ZODB
In directory cvs.zope.org:/tmp/cvs-serv24479
Modified Files:
lock_file.py
Log Message:
Don't use default argument to specify exception.
Log message on platforms where file-locking isn't supported.
=== ZODB3/ZODB/lock_file.py 1.6 => 1.7 ===
--- ZODB3/ZODB/lock_file.py:1.6 Wed Aug 14 18:07:09 2002
+++ ZODB3/ZODB/lock_file.py Tue Dec 3 13:49:33 2002
@@ -12,25 +12,24 @@
#
##############################################################################
-import POSException
+from ZODB.POSException import StorageSystemError
-# Try to create a function that creates Unix file locks. On windows
-# this will fail.
+# Try to create a function that creates Unix file locks.
try:
import fcntl
lock_file_FLAG = fcntl.LOCK_EX | fcntl.LOCK_NB
- def lock_file(file, error=POSException.StorageSystemError):
+ def lock_file(file):
try:
- un=file.fileno()
+ un = file.fileno()
except:
return # don't care if not a real file
try:
- fcntl.flock(un,lock_file_FLAG)
+ fcntl.flock(un, lock_file_FLAG)
except:
- raise error, (
+ raise StorageSystemError, (
"Could not lock the database file. There must be\n"
"another process that has opened the file.\n"
"<p>")
@@ -39,19 +38,21 @@
# Try windows-specific code:
try:
from winlock import LockFile
- def lock_file(file, error=POSException.StorageSystemError):
+ def lock_file(file):
try:
un=file.fileno()
except:
return # don't care if not a real file
try:
- LockFile(un,0,0,1,0) # just lock the first byte, who cares
+ LockFile(un, 0, 0, 1, 0) # just lock the first byte, who cares
except:
- raise error, (
+ raise StorageSystemError, (
"Could not lock the database file. There must be\n"
"another process that has opened the file.\n"
"<p>")
except:
- def lock_file(file, error=None):
- pass
+ import zLOG
+ def lock_file(file):
+ zLOG.LOG("FS", zLOG.INFO,
+ "No file-locking support on this platform")