summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/cooker.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/cooker.py')
-rw-r--r--bitbake/lib/bb/cooker.py52
1 files changed, 32 insertions, 20 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index d90bd3945f..6743bce585 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -13,7 +13,6 @@ import sys, os, glob, os.path, re, time
13import itertools 13import itertools
14import logging 14import logging
15import multiprocessing 15import multiprocessing
16import sre_constants
17import threading 16import threading
18from io import StringIO, UnsupportedOperation 17from io import StringIO, UnsupportedOperation
19from contextlib import closing 18from contextlib import closing
@@ -411,10 +410,7 @@ class BBCooker:
411 self.data.disableTracking() 410 self.data.disableTracking()
412 411
413 def parseConfiguration(self): 412 def parseConfiguration(self):
414 # Set log file verbosity 413 self.updateCacheSync()
415 verboselogs = bb.utils.to_boolean(self.data.getVar("BB_VERBOSE_LOGS", False))
416 if verboselogs:
417 bb.msg.loggerVerboseLogs = True
418 414
419 # Change nice level if we're asked to 415 # Change nice level if we're asked to
420 nice = self.data.getVar("BB_NICE_LEVEL") 416 nice = self.data.getVar("BB_NICE_LEVEL")
@@ -1022,6 +1018,11 @@ class BBCooker:
1022 if matches: 1018 if matches:
1023 bb.event.fire(bb.event.FilesMatchingFound(filepattern, matches), self.data) 1019 bb.event.fire(bb.event.FilesMatchingFound(filepattern, matches), self.data)
1024 1020
1021 def testCookerCommandEvent(self, filepattern):
1022 # Dummy command used by OEQA selftest to test tinfoil without IO
1023 matches = ["A", "B"]
1024 bb.event.fire(bb.event.FilesMatchingFound(filepattern, matches), self.data)
1025
1025 def findProviders(self, mc=''): 1026 def findProviders(self, mc=''):
1026 return bb.providers.findProviders(self.databuilder.mcdata[mc], self.recipecaches[mc], self.recipecaches[mc].pkg_pn) 1027 return bb.providers.findProviders(self.databuilder.mcdata[mc], self.recipecaches[mc], self.recipecaches[mc].pkg_pn)
1027 1028
@@ -1636,6 +1637,7 @@ class BBCooker:
1636 return 1637 return
1637 1638
1638 def post_serve(self): 1639 def post_serve(self):
1640 self.shutdown(force=True)
1639 prserv.serv.auto_shutdown() 1641 prserv.serv.auto_shutdown()
1640 if self.hashserv: 1642 if self.hashserv:
1641 self.hashserv.process.terminate() 1643 self.hashserv.process.terminate()
@@ -1650,6 +1652,7 @@ class BBCooker:
1650 1652
1651 if self.parser: 1653 if self.parser:
1652 self.parser.shutdown(clean=not force, force=force) 1654 self.parser.shutdown(clean=not force, force=force)
1655 self.parser.final_cleanup()
1653 1656
1654 def finishcommand(self): 1657 def finishcommand(self):
1655 self.state = state.initial 1658 self.state = state.initial
@@ -1791,7 +1794,7 @@ class CookerCollectFiles(object):
1791 try: 1794 try:
1792 re.compile(mask) 1795 re.compile(mask)
1793 bbmasks.append(mask) 1796 bbmasks.append(mask)
1794 except sre_constants.error: 1797 except re.error:
1795 collectlog.critical("BBMASK contains an invalid regular expression, ignoring: %s" % mask) 1798 collectlog.critical("BBMASK contains an invalid regular expression, ignoring: %s" % mask)
1796 1799
1797 # Then validate the combined regular expressions. This should never 1800 # Then validate the combined regular expressions. This should never
@@ -1799,7 +1802,7 @@ class CookerCollectFiles(object):
1799 bbmask = "|".join(bbmasks) 1802 bbmask = "|".join(bbmasks)
1800 try: 1803 try:
1801 bbmask_compiled = re.compile(bbmask) 1804 bbmask_compiled = re.compile(bbmask)
1802 except sre_constants.error: 1805 except re.error:
1803 collectlog.critical("BBMASK is not a valid regular expression, ignoring: %s" % bbmask) 1806 collectlog.critical("BBMASK is not a valid regular expression, ignoring: %s" % bbmask)
1804 bbmask = None 1807 bbmask = None
1805 1808
@@ -1931,7 +1934,8 @@ class Parser(multiprocessing.Process):
1931 except queue.Empty: 1934 except queue.Empty:
1932 pass 1935 pass
1933 else: 1936 else:
1934 self.results.cancel_join_thread() 1937 self.results.close()
1938 self.results.join_thread()
1935 break 1939 break
1936 1940
1937 if pending: 1941 if pending:
@@ -1940,6 +1944,8 @@ class Parser(multiprocessing.Process):
1940 try: 1944 try:
1941 job = self.jobs.pop() 1945 job = self.jobs.pop()
1942 except IndexError: 1946 except IndexError:
1947 self.results.close()
1948 self.results.join_thread()
1943 break 1949 break
1944 result = self.parse(*job) 1950 result = self.parse(*job)
1945 # Clear the siggen cache after parsing to control memory usage, its huge 1951 # Clear the siggen cache after parsing to control memory usage, its huge
@@ -2015,6 +2021,7 @@ class CookerParser(object):
2015 2021
2016 self.start() 2022 self.start()
2017 self.haveshutdown = False 2023 self.haveshutdown = False
2024 self.syncthread = None
2018 2025
2019 def start(self): 2026 def start(self):
2020 self.results = self.load_cached() 2027 self.results = self.load_cached()
@@ -2056,12 +2063,9 @@ class CookerParser(object):
2056 self.total) 2063 self.total)
2057 2064
2058 bb.event.fire(event, self.cfgdata) 2065 bb.event.fire(event, self.cfgdata)
2059 for process in self.processes: 2066
2060 self.parser_quit.put(None) 2067 for process in self.processes:
2061 else: 2068 self.parser_quit.put(None)
2062 self.parser_quit.cancel_join_thread()
2063 for process in self.processes:
2064 self.parser_quit.put(None)
2065 2069
2066 # Cleanup the queue before call process.join(), otherwise there might be 2070 # Cleanup the queue before call process.join(), otherwise there might be
2067 # deadlocks. 2071 # deadlocks.
@@ -2078,9 +2082,13 @@ class CookerParser(object):
2078 else: 2082 else:
2079 process.join() 2083 process.join()
2080 2084
2085 self.parser_quit.close()
2086 # Allow data left in the cancel queue to be discarded
2087 self.parser_quit.cancel_join_thread()
2088
2081 sync = threading.Thread(target=self.bb_cache.sync) 2089 sync = threading.Thread(target=self.bb_cache.sync)
2090 self.syncthread = sync
2082 sync.start() 2091 sync.start()
2083 multiprocessing.util.Finalize(None, sync.join, exitpriority=-100)
2084 bb.codeparser.parser_cache_savemerge() 2092 bb.codeparser.parser_cache_savemerge()
2085 bb.fetch.fetcher_parse_done() 2093 bb.fetch.fetcher_parse_done()
2086 if self.cooker.configuration.profile: 2094 if self.cooker.configuration.profile:
@@ -2094,6 +2102,10 @@ class CookerParser(object):
2094 bb.utils.process_profilelog(profiles, pout = pout) 2102 bb.utils.process_profilelog(profiles, pout = pout)
2095 print("Processed parsing statistics saved to %s" % (pout)) 2103 print("Processed parsing statistics saved to %s" % (pout))
2096 2104
2105 def final_cleanup(self):
2106 if self.syncthread:
2107 self.syncthread.join()
2108
2097 def load_cached(self): 2109 def load_cached(self):
2098 for filename, appends in self.fromcache: 2110 for filename, appends in self.fromcache:
2099 cached, infos = self.bb_cache.load(filename, appends) 2111 cached, infos = self.bb_cache.load(filename, appends)
@@ -2126,18 +2138,18 @@ class CookerParser(object):
2126 except bb.BBHandledException as exc: 2138 except bb.BBHandledException as exc:
2127 self.error += 1 2139 self.error += 1
2128 logger.error('Failed to parse recipe: %s' % exc.recipe) 2140 logger.error('Failed to parse recipe: %s' % exc.recipe)
2129 self.shutdown(clean=False) 2141 self.shutdown(clean=False, force=True)
2130 return False 2142 return False
2131 except ParsingFailure as exc: 2143 except ParsingFailure as exc:
2132 self.error += 1 2144 self.error += 1
2133 logger.error('Unable to parse %s: %s' % 2145 logger.error('Unable to parse %s: %s' %
2134 (exc.recipe, bb.exceptions.to_string(exc.realexception))) 2146 (exc.recipe, bb.exceptions.to_string(exc.realexception)))
2135 self.shutdown(clean=False) 2147 self.shutdown(clean=False, force=True)
2136 return False 2148 return False
2137 except bb.parse.ParseError as exc: 2149 except bb.parse.ParseError as exc:
2138 self.error += 1 2150 self.error += 1
2139 logger.error(str(exc)) 2151 logger.error(str(exc))
2140 self.shutdown(clean=False) 2152 self.shutdown(clean=False, force=True)
2141 return False 2153 return False
2142 except bb.data_smart.ExpansionError as exc: 2154 except bb.data_smart.ExpansionError as exc:
2143 self.error += 1 2155 self.error += 1
@@ -2146,7 +2158,7 @@ class CookerParser(object):
2146 tb = list(itertools.dropwhile(lambda e: e.filename.startswith(bbdir), exc.traceback)) 2158 tb = list(itertools.dropwhile(lambda e: e.filename.startswith(bbdir), exc.traceback))
2147 logger.error('ExpansionError during parsing %s', value.recipe, 2159 logger.error('ExpansionError during parsing %s', value.recipe,
2148 exc_info=(etype, value, tb)) 2160 exc_info=(etype, value, tb))
2149 self.shutdown(clean=False) 2161 self.shutdown(clean=False, force=True)
2150 return False 2162 return False
2151 except Exception as exc: 2163 except Exception as exc:
2152 self.error += 1 2164 self.error += 1
@@ -2158,7 +2170,7 @@ class CookerParser(object):
2158 # Most likely, an exception occurred during raising an exception 2170 # Most likely, an exception occurred during raising an exception
2159 import traceback 2171 import traceback
2160 logger.error('Exception during parse: %s' % traceback.format_exc()) 2172 logger.error('Exception during parse: %s' % traceback.format_exc())
2161 self.shutdown(clean=False) 2173 self.shutdown(clean=False, force=True)
2162 return False 2174 return False
2163 2175
2164 self.current += 1 2176 self.current += 1