Mercurial > p > roundup > code
diff roundup/backends/back_sqlite.py @ 2191:f7f6b6981a13
sqlite backend uses the global lock again
roundup-server uses ForkingMixIn (yay, simultaneous accesses with mysql
and postgresql)
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 07 Apr 2004 01:12:26 +0000 |
| parents | 7e595abb781e |
| children | 98d3bf8ffb19 |
line wrap: on
line diff
--- a/roundup/backends/back_sqlite.py Wed Apr 07 00:09:04 2004 +0000 +++ b/roundup/backends/back_sqlite.py Wed Apr 07 01:12:26 2004 +0000 @@ -1,4 +1,4 @@ -# $Id: back_sqlite.py,v 1.23 2004-03-31 23:08:08 richard Exp $ +# $Id: back_sqlite.py,v 1.24 2004-04-07 01:12:26 richard Exp $ '''Implements a backend for SQLite. See https://pysqlite.sourceforge.net/ for pysqlite info @@ -12,6 +12,7 @@ import os, base64, marshal from roundup import hyperdb, date, password +from roundup.backends import locking from roundup.backends import rdbms_common import sqlite @@ -57,6 +58,12 @@ # ensure files are group readable and writable os.umask(0002) + # lock the database + lockfilenm = os.path.join(self.dir, 'lock') + self.lockfile = locking.acquire_lock(lockfilenm) + self.lockfile.write(str(os.getpid())) + self.lockfile.flush() + (self.conn, self.cursor) = self.sql_open_connection() try: @@ -210,10 +217,17 @@ connection. ''' try: - self.conn.close() - except sqlite.ProgrammingError, value: - if str(value) != 'close failed - Connection is closed.': - raise + try: + self.conn.close() + except sqlite.ProgrammingError, value: + if str(value) != 'close failed - Connection is closed.': + raise + finally: + # always release the lock + if self.lockfile is not None: + locking.release_lock(self.lockfile) + self.lockfile.close() + self.lockfile = None def sql_rollback(self): ''' Squash any error caused by us having closed the connection (and
