diff options
-rw-r--r-- | bitbake/lib/bb/fetch/__init__.py | 9 | ||||
-rw-r--r-- | bitbake/lib/bb/persist_data.py | 11 |
2 files changed, 7 insertions, 13 deletions
diff --git a/bitbake/lib/bb/fetch/__init__.py b/bitbake/lib/bb/fetch/__init__.py index 668b788698..d8f5f167fc 100644 --- a/bitbake/lib/bb/fetch/__init__.py +++ b/bitbake/lib/bb/fetch/__init__.py | |||
@@ -144,14 +144,13 @@ def uri_replace(uri, uri_find, uri_replace, d): | |||
144 | methods = [] | 144 | methods = [] |
145 | urldata_cache = {} | 145 | urldata_cache = {} |
146 | saved_headrevs = {} | 146 | saved_headrevs = {} |
147 | persistent_database_connection = {} | ||
148 | 147 | ||
149 | def fetcher_init(d): | 148 | def fetcher_init(d): |
150 | """ | 149 | """ |
151 | Called to initialize the fetchers once the configuration data is known. | 150 | Called to initialize the fetchers once the configuration data is known. |
152 | Calls before this must not hit the cache. | 151 | Calls before this must not hit the cache. |
153 | """ | 152 | """ |
154 | pd = persist_data.PersistData(d, persistent_database_connection) | 153 | pd = persist_data.PersistData(d) |
155 | # When to drop SCM head revisions controlled by user policy | 154 | # When to drop SCM head revisions controlled by user policy |
156 | srcrev_policy = bb.data.getVar('BB_SRCREV_POLICY', d, 1) or "clear" | 155 | srcrev_policy = bb.data.getVar('BB_SRCREV_POLICY', d, 1) or "clear" |
157 | if srcrev_policy == "cache": | 156 | if srcrev_policy == "cache": |
@@ -180,7 +179,7 @@ def fetcher_compare_revisions(d): | |||
180 | return true/false on whether they've changed. | 179 | return true/false on whether they've changed. |
181 | """ | 180 | """ |
182 | 181 | ||
183 | pd = persist_data.PersistData(d, persistent_database_connection) | 182 | pd = persist_data.PersistData(d) |
184 | data = pd.getKeyValues("BB_URI_HEADREVS") | 183 | data = pd.getKeyValues("BB_URI_HEADREVS") |
185 | data2 = bb.fetch.saved_headrevs | 184 | data2 = bb.fetch.saved_headrevs |
186 | 185 | ||
@@ -758,7 +757,7 @@ class Fetch(object): | |||
758 | if not hasattr(self, "_latest_revision"): | 757 | if not hasattr(self, "_latest_revision"): |
759 | raise ParameterError | 758 | raise ParameterError |
760 | 759 | ||
761 | pd = persist_data.PersistData(d, persistent_database_connection) | 760 | pd = persist_data.PersistData(d) |
762 | key = self.generate_revision_key(url, ud, d) | 761 | key = self.generate_revision_key(url, ud, d) |
763 | rev = pd.getValue("BB_URI_HEADREVS", key) | 762 | rev = pd.getValue("BB_URI_HEADREVS", key) |
764 | if rev != None: | 763 | if rev != None: |
@@ -775,7 +774,7 @@ class Fetch(object): | |||
775 | if hasattr(self, "_sortable_revision"): | 774 | if hasattr(self, "_sortable_revision"): |
776 | return self._sortable_revision(url, ud, d) | 775 | return self._sortable_revision(url, ud, d) |
777 | 776 | ||
778 | pd = persist_data.PersistData(d, persistent_database_connection) | 777 | pd = persist_data.PersistData(d) |
779 | key = self.generate_revision_key(url, ud, d) | 778 | key = self.generate_revision_key(url, ud, d) |
780 | 779 | ||
781 | latest_rev = self._build_revision(url, ud, d) | 780 | latest_rev = self._build_revision(url, ud, d) |
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 |