diff options
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r-- | bitbake/lib/bb/persist_data.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/bitbake/lib/bb/persist_data.py b/bitbake/lib/bb/persist_data.py index 17620ef331..c4ea23bfda 100644 --- a/bitbake/lib/bb/persist_data.py +++ b/bitbake/lib/bb/persist_data.py | |||
@@ -47,9 +47,10 @@ if hasattr(sqlite3, 'enable_shared_cache'): | |||
47 | @total_ordering | 47 | @total_ordering |
48 | class SQLTable(collections.MutableMapping): | 48 | class SQLTable(collections.MutableMapping): |
49 | """Object representing a table/domain in the database""" | 49 | """Object representing a table/domain in the database""" |
50 | def __init__(self, cursor, table): | 50 | def __init__(self, cachefile, table): |
51 | self.cursor = cursor | 51 | self.cachefile = cachefile |
52 | self.table = table | 52 | self.table = table |
53 | self.cursor = connect(self.cachefile) | ||
53 | 54 | ||
54 | self._execute("CREATE TABLE IF NOT EXISTS %s(key TEXT, value TEXT);" | 55 | self._execute("CREATE TABLE IF NOT EXISTS %s(key TEXT, value TEXT);" |
55 | % table) | 56 | % table) |
@@ -63,6 +64,8 @@ class SQLTable(collections.MutableMapping): | |||
63 | except sqlite3.OperationalError as exc: | 64 | except sqlite3.OperationalError as exc: |
64 | if 'database is locked' in str(exc) and count < 500: | 65 | if 'database is locked' in str(exc) and count < 500: |
65 | count = count + 1 | 66 | count = count + 1 |
67 | self.cursor.close() | ||
68 | self.cursor = connect(self.cachefile) | ||
66 | continue | 69 | continue |
67 | raise | 70 | raise |
68 | 71 | ||
@@ -188,7 +191,7 @@ class PersistData(object): | |||
188 | del self.data[domain][key] | 191 | del self.data[domain][key] |
189 | 192 | ||
190 | def connect(database): | 193 | def connect(database): |
191 | return sqlite3.connect(database, timeout=30, isolation_level=None) | 194 | return sqlite3.connect(database, timeout=5, isolation_level=None) |
192 | 195 | ||
193 | def persist(domain, d): | 196 | def persist(domain, d): |
194 | """Convenience factory for SQLTable objects based upon metadata""" | 197 | """Convenience factory for SQLTable objects based upon metadata""" |
@@ -201,5 +204,4 @@ def persist(domain, d): | |||
201 | 204 | ||
202 | bb.utils.mkdirhier(cachedir) | 205 | bb.utils.mkdirhier(cachedir) |
203 | cachefile = os.path.join(cachedir, "bb_persist_data.sqlite3") | 206 | cachefile = os.path.join(cachedir, "bb_persist_data.sqlite3") |
204 | connection = connect(cachefile) | 207 | return SQLTable(cachefile, domain) |
205 | return SQLTable(connection, domain) | ||