1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-01 00:59:48 +00:00

bitbake persist_data: Add own retry logic

git-svn-id: https://svn.o-hand.com/repos/poky/trunk@2363 311d38ba-8fff-0310-9ca6-ca027cbcb966
This commit is contained in:
Richard Purdie
2007-08-04 22:12:42 +00:00
parent 9858ddb9c5
commit 71068e7cee
+16 -5
View File
@@ -50,7 +50,7 @@ class PersistData:
self.cachefile = os.path.join(self.cachedir,"bb_persist_data.sqlite3") self.cachefile = os.path.join(self.cachedir,"bb_persist_data.sqlite3")
bb.msg.debug(1, bb.msg.domain.PersistData, "Using '%s' as the persistent data cache" % self.cachefile) bb.msg.debug(1, bb.msg.domain.PersistData, "Using '%s' as the persistent data cache" % self.cachefile)
self.connection = sqlite3.connect(self.cachefile, timeout=5, isolation_level="IMMEDIATE") self.connection = sqlite3.connect(self.cachefile, timeout=5, isolation_level=None)
def addDomain(self, domain): def addDomain(self, domain):
""" """
@@ -82,14 +82,25 @@ class PersistData:
for row in data: for row in data:
rows = rows + 1 rows = rows + 1
if rows: if rows:
self.connection.execute("UPDATE %s SET value=? WHERE key=?;" % domain, [value, key]) self._execute("UPDATE %s SET value=? WHERE key=?;" % domain, [value, key])
else: else:
self.connection.execute("INSERT into %s(key, value) values (?, ?);" % domain, [key, value]) self._execute("INSERT into %s(key, value) values (?, ?);" % domain, [key, value])
self.connection.commit()
def delValue(self, domain, key): def delValue(self, domain, key):
""" """
Deletes a key/value pair Deletes a key/value pair
""" """
self.connection.execute("DELETE from %s where key=?;" % domain, [key]) self._execute("DELETE from %s where key=?;" % domain, [key])
def _execute(self, *query):
while True:
try:
self.connection.execute(query)
return
except pysqlite2.dbapi2.OperationalError, e:
if 'database is locked' in str(e):
continue
raise