summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2011-06-08 20:25:12 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-06-09 14:53:23 +0100
commitcd80d7f20164e6ce4ce7b0b99db56bb7297c116d (patch)
treec61ead5e76778ab420a291e288dae76f46ed5de6
parent3c3bd0c2fa80d747f25401c17b785c7c2f3787ca (diff)
downloadbitbake-cd80d7f20164e6ce4ce7b0b99db56bb7297c116d.tar.gz
persist_data: Add back code to retry in the case of locked database errors
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/persist_data.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/bb/persist_data.py b/lib/bb/persist_data.py
index 03adc7cc5..551b58a2a 100644
--- a/lib/bb/persist_data.py
+++ b/lib/bb/persist_data.py
@@ -55,7 +55,16 @@ class SQLTable(collections.MutableMapping):
% table)
def _execute(self, *query):
- return self.cursor.execute(*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
def __enter__(self):
self.cursor.__enter__()