Merge lp:~jameinel/u1db/reopen-db into lp:u1db

Proposed by John A Meinel
Status: Merged
Approved by: Samuele Pedroni
Approved revision: 125
Merged at revision: 126
Proposed branch: lp:~jameinel/u1db/reopen-db
Merge into: lp:u1db
Diff against target: 40 lines (+8/-2)
2 files modified
u1db/backends/sqlite_backend.py (+6/-2)
u1db/tests/test_sqlite_backend.py (+2/-0)
To merge this branch: bzr merge lp:~jameinel/u1db/reopen-db
Reviewer Review Type Date Requested Status
Ubuntu One hackers Pending
Review via email: mp+83397@code.launchpad.net

Description of the change

The existing test was failing on Windows, this gets it to pass, discussed with Samuele on IRC.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'u1db/backends/sqlite_backend.py'
2--- u1db/backends/sqlite_backend.py 2011-11-23 13:46:56 +0000
3+++ u1db/backends/sqlite_backend.py 2011-11-25 13:36:12 +0000
4@@ -53,10 +53,14 @@
5 if not os.path.isfile(sqlite_file):
6 raise errors.DatabaseDoesNotExist()
7 tries = 2
8- db_handle = dbapi2.connect(sqlite_file)
9- c = db_handle.cursor()
10 while tries:
11+ # Note: There seems to be a bug in sqlite 3.5.9 (with python2.6)
12+ # where without re-opening the database on Windows, it
13+ # doesn't see the transaction that was just committed
14+ db_handle = dbapi2.connect(sqlite_file)
15+ c = db_handle.cursor()
16 v, err = cls._which_index_storage(c)
17+ db_handle.close()
18 if v is not None:
19 break
20 # possibly another process is initializing it, wait for it to be
21
22=== modified file 'u1db/tests/test_sqlite_backend.py'
23--- u1db/tests/test_sqlite_backend.py 2011-11-23 12:35:52 +0000
24+++ u1db/tests/test_sqlite_backend.py 2011-11-25 13:36:12 +0000
25@@ -228,6 +228,7 @@
26 db = sqlite_backend.SQLitePartialExpandDatabase.__new__(
27 sqlite_backend.SQLitePartialExpandDatabase)
28 db._db_handle = dbapi2.connect(path) # db is there but not yet init-ed
29+ self.addCleanup(db.close)
30 observed = []
31 class SQLiteDatabaseTesting(sqlite_backend.SQLiteDatabase):
32 @classmethod
33@@ -237,6 +238,7 @@
34 observed.append(res[0])
35 return res
36 db2 = SQLiteDatabaseTesting._open_database(path)
37+ self.addCleanup(db2.close)
38 self.assertIsInstance(db2, sqlite_backend.SQLitePartialExpandDatabase)
39 self.assertEqual([None,
40 sqlite_backend.SQLitePartialExpandDatabase._index_storage_value],

Subscribers

People subscribed via source and target branches