]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
persist_data: handle locked db for SELECT
authorChris Larson <chris_larson@mentor.com>
Thu, 18 Nov 2010 17:54:10 +0000 (10:54 -0700)
committerChris Larson <chris_larson@mentor.com>
Thu, 18 Nov 2010 18:02:25 +0000 (11:02 -0700)
Parallel processes interacting with the persist_data db can quite easily
explode without this.

Signed-off-by: Chris Larson <chris_larson@mentor.com>
lib/bb/persist_data.py

index 91c089bdf195d484b7e13fd88cd649f0adb5e252..3c61d9573e8332198ea8dbb4a2195570244a02ec 100644 (file)
@@ -94,7 +94,7 @@ class PersistData:
         """
         Return the value of a key for a domain
         """
-        data = self.cursor.execute("SELECT * from %s where key=?;" % domain, [key])
+        data = self._execute("SELECT * from %s where key=?;" % domain, [key])
         for row in data:
             return row[1]
 
@@ -102,7 +102,7 @@ class PersistData:
         """
         Sets the value of a key for a domain
         """
-        data = self.cursor.execute("SELECT * from %s where key=?;" % domain, [key])
+        data = self._execute("SELECT * from %s where key=?;" % domain, [key])
         rows = 0
         for row in data:
             rows = rows + 1
@@ -120,8 +120,7 @@ class PersistData:
     def _execute(self, *query):
         while True:
             try:
-                self.cursor.execute(*query)
-                return
+                return self.cursor.execute(*query)
             except sqlite3.OperationalError as e:
                 if 'database is locked' in str(e):
                     continue