diff options
author | Chris Larson <chris_larson@mentor.com> | 2010-11-18 19:51:51 -0700 |
---|---|---|
committer | Chris Larson <chris_larson@mentor.com> | 2010-11-19 13:59:16 -0700 |
commit | 60b9b18eafad5ac46c7cf1048d749d673c2ee0ad (patch) | |
tree | ec982c4251853e1d02cb0f2c8ca6bb1d77f092b1 /lib/bb/persist_data.py | |
parent | 8da9744fcdf856abebcfbe9e3bc1b8cf07bc317b (diff) | |
download | bitbake-contrib-60b9b18eafad5ac46c7cf1048d749d673c2ee0ad.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.
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Diffstat (limited to 'lib/bb/persist_data.py')
-rw-r--r-- | lib/bb/persist_data.py | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/bb/persist_data.py b/lib/bb/persist_data.py index 3c61d9573..b574b45de 100644 --- a/lib/bb/persist_data.py +++ b/lib/bb/persist_data.py @@ -47,10 +47,7 @@ class PersistData: Why sqlite? It handles all the locking issues for us. """ - def __init__(self, d, persistent_database_connection): - if "connection" in persistent_database_connection: - self.cursor = persistent_database_connection["connection"].cursor() - return + def __init__(self, d): self.cachedir = bb.data.getVar("PERSISTENT_DIR", d, True) or bb.data.getVar("CACHE", d, True) if self.cachedir in [None, '']: bb.msg.fatal(bb.msg.domain.PersistData, "Please set the 'PERSISTENT_DIR' or 'CACHE' variable.") @@ -62,29 +59,27 @@ class PersistData: self.cachefile = os.path.join(self.cachedir, "bb_persist_data.sqlite3") logger.debug(1, "Using '%s' as the persistent data cache", self.cachefile) - connection = sqlite3.connect(self.cachefile, timeout=5, isolation_level=None) - persistent_database_connection["connection"] = connection - self.cursor = persistent_database_connection["connection"].cursor() + self.connection = sqlite3.connect(self.cachefile, timeout=5, isolation_level=None) def addDomain(self, domain): """ Should be called before any domain is used Creates it if it doesn't exist. """ - self.cursor.execute("CREATE TABLE IF NOT EXISTS %s(key TEXT, value TEXT);" % domain) + self.connection.execute("CREATE TABLE IF NOT EXISTS %s(key TEXT, value TEXT);" % domain) def delDomain(self, domain): """ Removes a domain and all the data it contains """ - self.cursor.execute("DROP TABLE IF EXISTS %s;" % domain) + self.connection.execute("DROP TABLE IF EXISTS %s;" % domain) def getKeyValues(self, domain): """ Return a list of key + value pairs for a domain """ ret = {} - data = self.cursor.execute("SELECT key, value from %s;" % domain) + data = self.connection.execute("SELECT key, value from %s;" % domain) for row in data: ret[str(row[0])] = str(row[1]) @@ -120,7 +115,7 @@ class PersistData: def _execute(self, *query): while True: try: - return self.cursor.execute(*query) + return self.connection.execute(*query) except sqlite3.OperationalError as e: if 'database is locked' in str(e): continue |