From: Chris Larson Date: Thu, 10 Feb 2011 00:56:42 +0000 (-0700) Subject: persist_data: handle lock in sqlite and use the shared cache X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=01d12f4f96447aeda48e504fb0708c2e0dc91e30;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git persist_data: handle lock in sqlite and use the shared cache Signed-off-by: Chris Larson --- diff --git a/lib/bb/persist_data.py b/lib/bb/persist_data.py index b5ce371d911..2c424f29bc4 100644 --- a/lib/bb/persist_data.py +++ b/lib/bb/persist_data.py @@ -39,6 +39,7 @@ if sqlversion[0] < 3 or (sqlversion[0] == 3 and sqlversion[1] < 3): logger = logging.getLogger("BitBake.PersistData") +sqlite3.enable_shared_cache(True) class SQLTable(collections.MutableMapping): @@ -51,16 +52,7 @@ class SQLTable(collections.MutableMapping): % table) def _execute(self, *query): - """Execute a query, waiting to acquire a lock if necessary""" - count = 0 - while True: - try: - return self.cursor.execute(*query) - except sqlite3.OperationalError as exc: - if 'database is locked' in str(exc) and count < 500: - count = count + 1 - continue - raise + return self.cursor.execute(*query) def __getitem__(self, key): data = self._execute("SELECT * from %s where key=?;" % @@ -159,7 +151,7 @@ class PersistData(object): del self.data[domain][key] def connect(database): - return sqlite3.connect(database, timeout=5, isolation_level=None) + return sqlite3.connect(database, timeout=30, isolation_level=None) def persist(domain, d): """Convenience factory for SQLTable objects based upon metadata"""