summaryrefslogtreecommitdiffstats
path: root/lib/bb/persist_data.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bb/persist_data.py')
-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__()