Commit ca108917 authored by Jeremy Hylton's avatar Jeremy Hylton

Don't use default argument to specify exception.

Log message on platforms where file-locking isn't supported.
parent aecc2d14
...@@ -12,25 +12,24 @@ ...@@ -12,25 +12,24 @@
# #
############################################################################## ##############################################################################
import POSException from ZODB.POSException import StorageSystemError
# Try to create a function that creates Unix file locks. On windows # Try to create a function that creates Unix file locks.
# this will fail.
try: try:
import fcntl import fcntl
lock_file_FLAG = fcntl.LOCK_EX | fcntl.LOCK_NB lock_file_FLAG = fcntl.LOCK_EX | fcntl.LOCK_NB
def lock_file(file, error=POSException.StorageSystemError): def lock_file(file):
try: try:
un=file.fileno() un = file.fileno()
except: except:
return # don't care if not a real file return # don't care if not a real file
try: try:
fcntl.flock(un,lock_file_FLAG) fcntl.flock(un, lock_file_FLAG)
except: except:
raise error, ( raise StorageSystemError, (
"Could not lock the database file. There must be\n" "Could not lock the database file. There must be\n"
"another process that has opened the file.\n" "another process that has opened the file.\n"
"<p>") "<p>")
...@@ -39,19 +38,21 @@ except: ...@@ -39,19 +38,21 @@ except:
# Try windows-specific code: # Try windows-specific code:
try: try:
from winlock import LockFile from winlock import LockFile
def lock_file(file, error=POSException.StorageSystemError): def lock_file(file):
try: try:
un=file.fileno() un=file.fileno()
except: except:
return # don't care if not a real file return # don't care if not a real file
try: 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: except:
raise error, ( raise StorageSystemError, (
"Could not lock the database file. There must be\n" "Could not lock the database file. There must be\n"
"another process that has opened the file.\n" "another process that has opened the file.\n"
"<p>") "<p>")
except: except:
def lock_file(file, error=None): import zLOG
pass def lock_file(file):
zLOG.LOG("FS", zLOG.INFO,
"No file-locking support on this platform")
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