Commit 251aad2f authored by Barry Warsaw's avatar Barry Warsaw

Backported from ZODB4, use the lock_file.LockFile class to

encapsulation the storage lock file.
parent 95448299
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
# may have a back pointer to a version record or to a non-version # may have a back pointer to a version record or to a non-version
# record. # record.
# #
__version__='$Revision: 1.126 $'[11:-2] __version__='$Revision: 1.127 $'[11:-2]
import base64 import base64
from cPickle import Pickler, Unpickler, loads from cPickle import Pickler, Unpickler, loads
...@@ -135,7 +135,7 @@ except: ...@@ -135,7 +135,7 @@ except:
from ZODB import BaseStorage, ConflictResolution, POSException from ZODB import BaseStorage, ConflictResolution, POSException
from ZODB.POSException import UndoError, POSKeyError, MultipleUndoErrors from ZODB.POSException import UndoError, POSKeyError, MultipleUndoErrors
from ZODB.TimeStamp import TimeStamp from ZODB.TimeStamp import TimeStamp
from ZODB.lock_file import lock_file from ZODB.lock_file import LockFile
from ZODB.utils import p64, u64, cp, z64 from ZODB.utils import p64, u64, cp, z64
try: try:
...@@ -225,18 +225,8 @@ class FileStorage(BaseStorage.BaseStorage, ...@@ -225,18 +225,8 @@ class FileStorage(BaseStorage.BaseStorage,
# Lock the database and set up the temp file. # Lock the database and set up the temp file.
if not read_only: if not read_only:
try: # Create the lock file
f = open(file_name + '.lock', 'r+') self._lock_file = LockFile(file_name + '.lock')
except:
f = open(file_name+'.lock', 'w+')
lock_file(f)
try:
f.write(str(os.getpid()))
f.flush()
except:
pass
self._lock_file = f # so it stays open
self._tfile = open(file_name + '.tmp', 'w+b') self._tfile = open(file_name + '.tmp', 'w+b')
else: else:
self._tfile = None self._tfile = None
......
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