[Zope3-checkins] CVS: Zope3/src/zodb/storage - base.py:1.16

Barry Warsaw barry@wooz.org
Thu, 27 Feb 2003 18:20:14 -0500


Update of /cvs-repository/Zope3/src/zodb/storage
In directory cvs.zope.org:/tmp/cvs-serv15035

Modified Files:
	base.py 
Log Message:
env_from_string(), _doclose(): Use the new LockFile class.



=== Zope3/src/zodb/storage/base.py 1.15 => 1.16 ===
--- Zope3/src/zodb/storage/base.py:1.15	Tue Feb 25 13:55:03 2003
+++ Zope3/src/zodb/storage/base.py	Thu Feb 27 18:20:13 2003
@@ -45,7 +45,7 @@
 from zodb.storage.interfaces import StorageTransactionError, ReadOnlyError
 # BaseStorage provides primitives for lock acquisition and release, and a host
 # of other methods, some of which are overridden here, some of which are not.
-from zodb.lockfile import lock_file
+from zodb.lockfile import LockFile
 from zodb.serialize import findrefs
 
 ZERO = '\0'*8
@@ -691,10 +691,8 @@
         # can't hurt and is more robust.
         self._env.txn_checkpoint(0, 0, db.DB_FORCE)
         self._env.txn_checkpoint(0, 0, db.DB_FORCE)
-        lockfile = os.path.join(self._env.db_home, '.lock')
         self._lockfile.close()
         self._env.close()
-        os.unlink(lockfile)
 
     # A couple of convenience methods
     def _update(self, deltas, data, incdec):
@@ -756,15 +754,7 @@
     # This is required in order to work around the Berkeley lock
     # exhaustion problem (i.e. we do our own application level locks
     # rather than rely on Berkeley's finite page locks).
-    lockpath = os.path.join(envdir, '.lock')
-    try:
-        lockfile = open(lockpath, 'r+')
-    except IOError, e:
-        if e.errno <> errno.ENOENT: raise
-        lockfile = open(lockpath, 'w+')
-    lock_file(lockfile)
-    lockfile.write(str(os.getpid()))
-    lockfile.flush()
+    lockfile = LockFile(os.path.join(envdir, '.lock'))
     try:
         # Create, initialize, and open the environment
         env = db.DBEnv()