summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/persist_data.py
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-11-18 19:51:51 -0700
committerRichard Purdie <rpurdie@linux.intel.com>2011-01-05 00:58:23 +0000
commit3069c0b2588c9e88a4fa2fd4d37356410d364410 (patch)
treee0f101e24b50feb9c014c8d3ed98baf62b915467 /bitbake/lib/bb/persist_data.py
parent30d27115ec38b8191d81504858d105b0d91277d8 (diff)
downloadpoky-3069c0b2588c9e88a4fa2fd4d37356410d364410.tar.gz
Revert "persist_data: cache connection and use cursor"
Caching the database connection can cause serious issues if it results in multiple processes (e.g. multiple tasks) simultaneously using the same connection. This reverts commit 8a6876752b90efd81d92f0947bfc9527d8260969. (Bitbake rev: 60b9b18eafad5ac46c7cf1048d749d673c2ee0ad) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb/persist_data.py')
-rw-r--r--bitbake/lib/bb/persist_data.py11
1 files changed, 3 insertions, 8 deletions
diff --git a/bitbake/lib/bb/persist_data.py b/bitbake/lib/bb/persist_data.py
index 76bff16658..9558e71283 100644
--- a/bitbake/lib/bb/persist_data.py
+++ b/bitbake/lib/bb/persist_data.py
@@ -47,10 +47,7 @@ class PersistData:
47 47
48 Why sqlite? It handles all the locking issues for us. 48 Why sqlite? It handles all the locking issues for us.
49 """ 49 """
50 def __init__(self, d, persistent_database_connection): 50 def __init__(self, d):
51 if "connection" in persistent_database_connection:
52 self.cursor = persistent_database_connection["connection"].cursor()
53 return
54 self.cachedir = bb.data.getVar("PERSISTENT_DIR", d, True) or bb.data.getVar("CACHE", d, True) 51 self.cachedir = bb.data.getVar("PERSISTENT_DIR", d, True) or bb.data.getVar("CACHE", d, True)
55 if self.cachedir in [None, '']: 52 if self.cachedir in [None, '']:
56 bb.msg.fatal(bb.msg.domain.PersistData, "Please set the 'PERSISTENT_DIR' or 'CACHE' variable.") 53 bb.msg.fatal(bb.msg.domain.PersistData, "Please set the 'PERSISTENT_DIR' or 'CACHE' variable.")
@@ -62,9 +59,7 @@ class PersistData:
62 self.cachefile = os.path.join(self.cachedir, "bb_persist_data.sqlite3") 59 self.cachefile = os.path.join(self.cachedir, "bb_persist_data.sqlite3")
63 logger.debug(1, "Using '%s' as the persistent data cache", self.cachefile) 60 logger.debug(1, "Using '%s' as the persistent data cache", self.cachefile)
64 61
65 connection = sqlite3.connect(self.cachefile, timeout=5, isolation_level=None) 62 self.connection = sqlite3.connect(self.cachefile, timeout=5, isolation_level=None)
66 persistent_database_connection["connection"] = connection
67 self.cursor = persistent_database_connection["connection"].cursor()
68 63
69 def addDomain(self, domain): 64 def addDomain(self, domain):
70 """ 65 """
@@ -127,7 +122,7 @@ class PersistData:
127 count = 0 122 count = 0
128 while True: 123 while True:
129 try: 124 try:
130 return self.cursor.execute(*query) 125 return self.connection.execute(*query)
131 except sqlite3.OperationalError as e: 126 except sqlite3.OperationalError as e:
132 if 'database is locked' in str(e) and count < 500: 127 if 'database is locked' in str(e) and count < 500:
133 count = count + 1 128 count = count + 1